package com.hutao.manage.service.impl;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hutao.manage.constant.Constant;
import com.hutao.manage.mapper.FeelOdSphMapper;
import com.hutao.manage.mapper.MrInBasicMapper;
import com.hutao.manage.mapper.StatisticalReportParamMapper;
import com.hutao.manage.mapper.TBaBaseMapper;
import com.hutao.manage.mapper.TBnssczMapper;
import com.hutao.manage.model.AvgInHospDaysInfo;
import com.hutao.manage.model.BaseDataRecord;
import com.hutao.manage.model.BedIndexInfo;
import com.hutao.manage.model.BedIndexRecord;
import com.hutao.manage.model.CostFeeChartRecord;
import com.hutao.manage.model.CostFeeInfo;
import com.hutao.manage.model.DiagTop10DeptInfo;
import com.hutao.manage.model.DiagTop10DeptRecord;
import com.hutao.manage.model.DiagTop20OrderInfo;
import com.hutao.manage.model.EchartsBaseRecord;
import com.hutao.manage.model.GeneralPerformace;
import com.hutao.manage.model.Major20DiagInfo;
import com.hutao.manage.model.OpNumberInfo;
import com.hutao.manage.model.OperationTop20Info;
import com.hutao.manage.model.OutHospStatisIndexInfo;
import com.hutao.manage.model.OutHospStatisIndexItem;
import com.hutao.manage.model.OutHospStatisIndexRecord;
import com.hutao.manage.model.OutNumDeathRateInfo;
import com.hutao.manage.model.OutPatientAgeInfo;
import com.hutao.manage.model.OutPatientAgeRecord;
import com.hutao.manage.model.OutPatientAreaInfo;
import com.hutao.manage.model.OutPatientAreaRecord;
import com.hutao.manage.model.OutPatientFeeInfo;
import com.hutao.manage.model.OutPatientJzyslxInfo;
import com.hutao.manage.model.OutPatientVisitInfo;
import com.hutao.manage.model.OutPatientZtqkInfo;
import com.hutao.manage.model.OutSatisContrastAnalysisInfo;
import com.hutao.manage.model.OutSatisContrastAnalysisRecord;
import com.hutao.manage.model.OutpatientAppointmentInfo;
import com.hutao.manage.model.OutpatientDeptInfo;
import com.hutao.manage.model.OutpatientDiagTop20Info;
import com.hutao.manage.model.OutpatientDiagTop20Record;
import com.hutao.manage.model.OutpatientSatisfactionInfo;
import com.hutao.manage.model.OutpatientSatisfactionRecord;
import com.hutao.manage.model.OutpatientSexInfo;
import com.hutao.manage.model.Performance;
import com.hutao.manage.model.PerformanceInfo;
import com.hutao.manage.model.QcAcquiredInfo;
import com.hutao.manage.model.QcAcquiredRecord;
import com.hutao.manage.model.QcBackInfo;
import com.hutao.manage.model.QcBackRecord;
import com.hutao.manage.model.QualityInfo;
import com.hutao.manage.model.QualityRecord;
import com.hutao.manage.model.SingleDiagQcInfo;
import com.hutao.manage.model.SingleDiagQcRecord;
import com.hutao.manage.model.SsrsPerformance;
import com.hutao.manage.model.TopOrderRecord;
import com.hutao.manage.pojo.BaseForSS;
import com.hutao.manage.pojo.BaseForTj;
import com.hutao.manage.pojo.BedIndex;
import com.hutao.manage.pojo.CostFee;
import com.hutao.manage.pojo.DiagRank;
import com.hutao.manage.pojo.DiagTop20DTO;
import com.hutao.manage.pojo.FeelOdStatistics;
import com.hutao.manage.pojo.MedicalQuality;
import com.hutao.manage.pojo.OperationNumber;
import com.hutao.manage.pojo.OperationRank;
import com.hutao.manage.pojo.OutPatientAge;
import com.hutao.manage.pojo.OutpatientAppointmnet;
import com.hutao.manage.pojo.OutpatientArea;
import com.hutao.manage.pojo.OutpatientDept;
import com.hutao.manage.pojo.OutpatientDiagTop20;
import com.hutao.manage.pojo.OutpatientFee;
import com.hutao.manage.pojo.OutpatientJzyslx;
import com.hutao.manage.pojo.OutpatientSex;
import com.hutao.manage.pojo.OutpatientVisit;
import com.hutao.manage.pojo.PageParam;
import com.hutao.manage.pojo.QcDeath;
import com.hutao.manage.pojo.RepeatInHosp;
import com.hutao.manage.pojo.StatisticalReportParam;
import com.hutao.manage.pojo.StdQcIndex;
import com.hutao.manage.pojo.TTjBzfl;
import com.hutao.manage.pojo.Top20DTO;
import com.hutao.manage.pojo.Universal;
import com.hutao.manage.query.CybingrenTJSearch;
import com.hutao.manage.query.MrInBasicQuery;
import com.hutao.manage.query.OutPatientParam;
import com.hutao.manage.service.MedicalService;
import com.hutao.manage.util.BigDecimalUtil;
import com.hutao.manage.util.CyTianshuDataUtil;
import com.hutao.manage.util.CytianshuData;
import com.hutao.manage.util.DateUtil;
import com.hutao.manage.util.HttpClientUtil;
import com.hutao.manage.util.JsonUtil;
import com.hutao.manage.util.NumUtil;
import com.hutao.manage.util.NumberUtil;
import com.hutao.manage.util.StringUtil;
import com.hutao.manage.util.TongJiSaqlUtil;

@Service
public class MedicalServiceImpl implements MedicalService {
	
	private Logger logger = LoggerFactory.getLogger(MedicalServiceImpl.class);

	@Autowired
	private MrInBasicMapper mrInBasicMapper;

	@Autowired
	private FeelOdSphMapper feelOdSphMapper;
	
	@Autowired
	private TBaBaseMapper tBaBaseMapper;
	
	@Autowired
	private TBnssczMapper tBnssczMapper;

	@Autowired
	private StatisticalReportParamMapper statisticalReportParamMapper;

	@Transactional(readOnly = true)
	@Override
	public DiagTop20OrderInfo getDiagOrderTop20(StatisticalReportParam statisticalReportParam, String orgCode,
			String outWay) {

		String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		
		
		//DiagTop20OrderInfo diagTop20OrderInfo = this.getDiagTop20OrderInfo(startTime1, endTime1, orgCode, outWay);
		
		DiagTop20OrderInfo diagTop20OrderInfo = this.getNewDiagTop20OrderInfo(startTime1, endTime1, orgCode, outWay);

		String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
		String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
		
		
		//DiagTop20OrderInfo preMonthDiagTop20OrderInfo = this.getDiagTop20OrderInfo(startTime2, endTime2, orgCode,
		//		outWay);
		
		DiagTop20OrderInfo preMonthDiagTop20OrderInfo = this.getNewDiagTop20OrderInfo(startTime2, endTime2, orgCode, outWay);

		String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
		String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());
		
		
		DiagTop20OrderInfo lastYearDiagTop20OrderInfo = this.getNewDiagTop20OrderInfo(startTime3, endTime3, orgCode, outWay);
		//DiagTop20OrderInfo lastYearDiagTop20OrderInfo = this.getDiagTop20OrderInfo(startTime3, endTime3, orgCode,
		//		outWay);
		diagTop20OrderInfo.setPreMonthtop20diagOrderRecords(preMonthDiagTop20OrderInfo.getTop20diagOrderRecords());
		diagTop20OrderInfo.setLastYeartop20diagOrderRecords(lastYearDiagTop20OrderInfo.getTop20diagOrderRecords());

		List<Top20DTO> top20DTOList = new LinkedList<>();
		List<TopOrderRecord> list1 = diagTop20OrderInfo.getTop20diagOrderRecords();
		List<TopOrderRecord> list2 = diagTop20OrderInfo.getPreMonthtop20diagOrderRecords();
		List<TopOrderRecord> list3 = diagTop20OrderInfo.getLastYeartop20diagOrderRecords();
		Top20DTO top20DTO = null;
		for (int i = 0; i < list1.size(); i++) {
			TopOrderRecord record1 = list1.get(i);
			TopOrderRecord record2 = list2.get(i);
			TopOrderRecord record3 = list3.get(i);
			top20DTO = new Top20DTO();

			top20DTO.setTopOrder(record1.getTopOrder() == null ? "" : record1.getTopOrder());
			top20DTO.setDiagCode1(record1.getDiagCode() == null ? "" : record1.getDiagCode());
			top20DTO.setDiagName1(record1.getDiagName() == null ? "" : record1.getDiagName());
			top20DTO.setDiagNum1(record1.getDiagNum());
			top20DTO.setAvgInHospDays1(record1.getAvgInHospDays());
			top20DTO.setAvgCostFee1(record1.getAvgCostFee());

			top20DTO.setDiagCode2(record2.getDiagCode());
			top20DTO.setDiagName2(record2.getDiagName());
			top20DTO.setDiagNum2(record2.getDiagNum());
			top20DTO.setAvgInHospDays2(record2.getAvgInHospDays());
			top20DTO.setAvgCostFee2(record2.getAvgCostFee());

			top20DTO.setDiagCode3(record3.getDiagCode());
			top20DTO.setDiagName3(record3.getDiagName());
			top20DTO.setDiagNum3(record3.getDiagNum());
			top20DTO.setAvgInHospDays3(record3.getAvgInHospDays());
			top20DTO.setAvgCostFee3(record3.getAvgCostFee());

			if (record1.getTopOrder().equals("合计")) {
				top20DTO.setTopOrder("");
				top20DTO.setDiagCode1("合计");
			}

			System.out.println(top20DTO);

			top20DTOList.add(top20DTO);
		}

		diagTop20OrderInfo.setTop20DTOList(top20DTOList);

		return diagTop20OrderInfo;
	}
	
	
	public DiagTop20OrderInfo getNewDiagTop20OrderInfo(String startTime, String endTime, String orgCode, String outWay) {
		
		// 查询当前出院时间所有的疾病编码
		
		//查询类目疾病统计信息
		List<QualityRecord> qualityRecords = this.getQualityList(startTime, endTime, orgCode, null, "1000","3");
		
		Integer totalNum = 0;
		for (QualityRecord qualityRecord : qualityRecords) {
			totalNum += qualityRecord.getDischarges();
		}

		int i = 1;
		int top20Total = 0;
		int top20DeathNum = 0;
		DiagTop20OrderInfo diagTop20OrderInfo = new DiagTop20OrderInfo();
		double totalNumDou = Double.valueOf(totalNum.toString());
		List<TopOrderRecord> topOrderRecordList = new LinkedList<>();
		TopOrderRecord topOrderRecord = null;
		for (QualityRecord qualityRecord : qualityRecords) {
			topOrderRecord = new TopOrderRecord();
			if (i > 20) {
				continue;
			}
			topOrderRecord.setDiagCode(qualityRecord.getSpecies());
			
		

			double codeNumDou = Double.valueOf(qualityRecord.getDischarges());

			double rate = NumUtil.div(codeNumDou, totalNumDou, 4) * 100;

			top20Total += qualityRecord.getDischarges();
			top20DeathNum += qualityRecord.getDeaths();

			topOrderRecord.setDiagName(qualityRecord.getSpeciesN());
			topOrderRecord.setDiagNum(qualityRecord.getDischarges());
			topOrderRecord.setDiagNumRate(NumUtil.round(rate, 2));
			topOrderRecord.setTopOrder(i + "");
			topOrderRecord.setDeathNum(qualityRecord.getDeaths());
			topOrderRecord.setAvgInHospDays(new BigDecimal(qualityRecord.getAverageStay()).setScale(2, BigDecimal.ROUND_HALF_UP));
			topOrderRecord.setAvgCostFee(new BigDecimal(qualityRecord.getCostPer()).setScale(2, BigDecimal.ROUND_HALF_UP));
			topOrderRecordList.add(topOrderRecord);
			if (i == 1)
				diagTop20OrderInfo.setTop1Record(topOrderRecord);
			if (i == 2)
				diagTop20OrderInfo.setTop2Record(topOrderRecord);
			if (i == 3)
				diagTop20OrderInfo.setTop3Record(topOrderRecord);
			if (i == 4)
				diagTop20OrderInfo.setTop4Record(topOrderRecord);
			if (i == 5)
				diagTop20OrderInfo.setTop5Record(topOrderRecord);

			i++;

		}

		topOrderRecord = new TopOrderRecord();
		topOrderRecord.setTopOrder("合计");
		topOrderRecord.setDiagNum(top20Total);
		topOrderRecord.setDiagNumRate(NumUtil.round(NumUtil.div(top20Total, totalNum, 4) * 100, 2));
		topOrderRecord.setDeathNum(top20DeathNum);
		topOrderRecordList.add(topOrderRecord);

		diagTop20OrderInfo.setTotalOutNum(totalNum);
		diagTop20OrderInfo.setTop20TotalOutNum(top20Total);
		diagTop20OrderInfo.setTop20TotalOutNumRate(NumUtil.round(NumUtil.div(top20Total, totalNum, 4) * 100, 2));
		diagTop20OrderInfo.setTop20diagOrderRecords(topOrderRecordList);
		return diagTop20OrderInfo;
	}
	
	

	public DiagTop20OrderInfo getDiagTop20OrderInfo(String startTime, String endTime, String orgCode, String outWay) {
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);
		mrInBasicQuery.setOutWay(outWay);
		// 查询当前出院时间所有的疾病编码
		List<DiagRank> diagRankList = mrInBasicMapper.getDiagRank(mrInBasicQuery);
		Integer totalNum = 0;
		for (DiagRank diagRank : diagRankList) {
			totalNum += diagRank.getCodeNum();
		}

		int i = 1;
		int top20Total = 0;
		int top20DeathNum = 0;
		DiagTop20OrderInfo diagTop20OrderInfo = new DiagTop20OrderInfo();
		double totalNumDou = Double.valueOf(totalNum.toString());
		List<TopOrderRecord> topOrderRecordList = new LinkedList<>();
		TopOrderRecord topOrderRecord = null;
		for (DiagRank diagRank : diagRankList) {
			topOrderRecord = new TopOrderRecord();
			if (i > 20) {
				continue;
			}
			String code = diagRank.getCode();
			topOrderRecord.setDiagCode(code);
			String preCode = null;
			if (StringUtils.isBlank(code)) {
				continue;
			}
			if (code.contains(".x")) {
				preCode = code.substring(0, 3);
			} else {
				preCode = code.substring(0, 5);
			}

			List<String> diagNames = mrInBasicMapper.getDiagNameByCode(preCode);

			if (CollectionUtils.isEmpty(diagNames)) {
				diagNames = mrInBasicMapper.getDiagNameByCode(preCode + "+");
				topOrderRecord.setDiagCode(preCode + "+");
			}
			diagRank.setCodeName(CollectionUtils.isEmpty(diagNames) ? null : diagNames.get(0));

			double codeNumDou = Double.valueOf(diagRank.getCodeNum());

			double rate = NumUtil.div(codeNumDou, totalNumDou, 4) * 100;

			top20Total += diagRank.getCodeNum();
			top20DeathNum += diagRank.getDeathNum();

			topOrderRecord.setDiagName(diagRank.getCodeName());
			topOrderRecord.setDiagNum(diagRank.getCodeNum());
			topOrderRecord.setDiagNumRate(NumUtil.round(rate, 2));
			topOrderRecord.setTopOrder(i + "");
			topOrderRecord.setDeathNum(diagRank.getDeathNum());
			topOrderRecord.setAvgInHospDays(diagRank.getAvgInHospDays());
			topOrderRecord.setAvgCostFee(diagRank.getAvgFee());
			topOrderRecordList.add(topOrderRecord);
			if (i == 1)
				diagTop20OrderInfo.setTop1Record(topOrderRecord);
			if (i == 2)
				diagTop20OrderInfo.setTop2Record(topOrderRecord);
			if (i == 3)
				diagTop20OrderInfo.setTop3Record(topOrderRecord);
			if (i == 4)
				diagTop20OrderInfo.setTop4Record(topOrderRecord);
			if (i == 5)
				diagTop20OrderInfo.setTop5Record(topOrderRecord);

			i++;

		}

		topOrderRecord = new TopOrderRecord();
		topOrderRecord.setTopOrder("合计");
		topOrderRecord.setDiagNum(top20Total);
		topOrderRecord.setDiagNumRate(NumUtil.round(NumUtil.div(top20Total, totalNum, 4) * 100, 2));
		topOrderRecord.setDeathNum(top20DeathNum);
		topOrderRecordList.add(topOrderRecord);

		diagTop20OrderInfo.setTotalOutNum(totalNum);
		diagTop20OrderInfo.setTop20TotalOutNum(top20Total);
		diagTop20OrderInfo.setTop20TotalOutNumRate(NumUtil.round(NumUtil.div(top20Total, totalNum, 4) * 100, 2));
		diagTop20OrderInfo.setTop20diagOrderRecords(topOrderRecordList);
		return diagTop20OrderInfo;
	}

	@Override
	public DiagTop20OrderInfo getDeathSequence(StatisticalReportParam statisticalReportParam, String orgCode,
			String outWay) {

		String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		DiagTop20OrderInfo diagTop20OrderInfo = this.getSubDeathSequence(startTime1, endTime1, orgCode, outWay);

		String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
		String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
		DiagTop20OrderInfo preMonthDiagTop20OrderInfo = this.getSubDeathSequence(startTime2, endTime2, orgCode, outWay);

		String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
		String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());
		DiagTop20OrderInfo lastYearMonthDiagTop20OrderInfo = this.getSubDeathSequence(startTime3, endTime3, orgCode,
				outWay);

		diagTop20OrderInfo.setPreMonthtop20diagOrderRecords(preMonthDiagTop20OrderInfo.getTop20diagOrderRecords());

		diagTop20OrderInfo.setLastYeartop20diagOrderRecords(lastYearMonthDiagTop20OrderInfo.getTop20diagOrderRecords());
		
		List<Top20DTO> top20DTOList = new LinkedList<>();
		List<TopOrderRecord> list1 = diagTop20OrderInfo.getTop20diagOrderRecords();
		List<TopOrderRecord> list2 = diagTop20OrderInfo.getPreMonthtop20diagOrderRecords();
		List<TopOrderRecord> list3 = diagTop20OrderInfo.getLastYeartop20diagOrderRecords();
		Top20DTO top20DTO = null;
		for (int i = 0; i < list1.size(); i++) {
			TopOrderRecord record1 = list1.get(i);
			TopOrderRecord record2 = list2.get(i);
			TopOrderRecord record3 = list3.get(i);
			top20DTO = new Top20DTO();

			top20DTO.setTopOrder(record1.getTopOrder() == null ? "" : record1.getTopOrder());
			top20DTO.setDiagCode1(record1.getDiagCode() == null ? "" : record1.getDiagCode());
			top20DTO.setDiagName1(record1.getDiagName() == null ? "" : record1.getDiagName());
			top20DTO.setDiagNum1(record1.getDiagNum());
			top20DTO.setAvgInHospDays1(record1.getAvgInHospDays());
			top20DTO.setAvgCostFee1(record1.getAvgCostFee());

			top20DTO.setDiagCode2(record2.getDiagCode());
			top20DTO.setDiagName2(record2.getDiagName());
			top20DTO.setDiagNum2(record2.getDiagNum());
			top20DTO.setAvgInHospDays2(record2.getAvgInHospDays());
			top20DTO.setAvgCostFee2(record2.getAvgCostFee());

			top20DTO.setDiagCode3(record3.getDiagCode());
			top20DTO.setDiagName3(record3.getDiagName());
			top20DTO.setDiagNum3(record3.getDiagNum());
			top20DTO.setAvgInHospDays3(record3.getAvgInHospDays());
			top20DTO.setAvgCostFee3(record3.getAvgCostFee());

			if (record1.getTopOrder().equals("合计")) {
				top20DTO.setTopOrder("");
				top20DTO.setDiagCode1("合计");
			}

			System.out.println(top20DTO);

			top20DTOList.add(top20DTO);
		}
		
		diagTop20OrderInfo.setTop20DTOList(top20DTOList);


		return diagTop20OrderInfo;
	}

	public DiagTop20OrderInfo getSubDeathSequence(String startTime, String endTime, String orgCode, String outWay) {
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);
		mrInBasicQuery.setOutWay(outWay);
		// 查询当前出院时间所有的疾病编码
		List<DiagRank> diagRankList = mrInBasicMapper.getDiagRank(mrInBasicQuery);
		Integer deathTotalNum = 0;
		for (DiagRank diagRank : diagRankList) {
			deathTotalNum += diagRank.getDeathNum();
		}

		Collections.sort(diagRankList, new Comparator<DiagRank>() {

			@Override
			public int compare(DiagRank o1, DiagRank o2) {
				// TODO Auto-generated method stub
				return o2.getDeathNum() - o1.getDeathNum();
			}
		});

		int i = 1;
		int top20Total = 0;
		int top20DeathNum = 0;
		double top20DeathNumRate = 0;
		DiagTop20OrderInfo diagTop20OrderInfo = new DiagTop20OrderInfo();
		double totalNumDou = Double.valueOf(deathTotalNum.toString());
		List<TopOrderRecord> topOrderRecordList = new LinkedList<>();
		TopOrderRecord topOrderRecord = null;
		for (DiagRank diagRank : diagRankList) {
			topOrderRecord = new TopOrderRecord();
			if (i > 20) {
				continue;
			}

			String code = diagRank.getCode();
			String preCode = null;
			if (StringUtils.isBlank(code)) {
				continue;
			}
			topOrderRecord.setDiagCode(code);

//			if (code.contains(".x")) {
//				preCode = code.substring(0, 3);
//			} else {
//				preCode = code.substring(0, 5);
//			}

			List<String> diagNames = mrInBasicMapper.getDiagNameByCode(code);

			if (CollectionUtils.isEmpty(diagNames)) {
				diagNames = mrInBasicMapper.getDiagNameByCode(preCode + "+");
			}
			diagRank.setCodeName(CollectionUtils.isEmpty(diagNames) ? null : diagNames.get(0));

			// double codeNumDou = Double.valueOf(diagRank.getCodeNum()) ;

			double rate = NumUtil.div(diagRank.getDeathNum(), totalNumDou, 4) * 100;

			top20Total += diagRank.getCodeNum();
			top20DeathNum += diagRank.getDeathNum();

			topOrderRecord.setDiagName(diagRank.getCodeName());
			topOrderRecord.setDiagNum(diagRank.getCodeNum());
			topOrderRecord.setDiagNumRate(NumUtil.round(rate, 2));
			topOrderRecord.setTopOrder(i + "");
			topOrderRecord.setDeathNum(diagRank.getDeathNum());
			topOrderRecord.setAvgInHospDays(diagRank.getAvgInHospDays());
			topOrderRecord.setAvgCostFee(diagRank.getAvgFee());
			topOrderRecordList.add(topOrderRecord);
			if (i == 1)
				diagTop20OrderInfo.setTop1Record(topOrderRecord);
			if (i == 2)
				diagTop20OrderInfo.setTop2Record(topOrderRecord);
			if (i == 3)
				diagTop20OrderInfo.setTop3Record(topOrderRecord);
			if (i == 4)
				diagTop20OrderInfo.setTop4Record(topOrderRecord);
			if (i == 5)
				diagTop20OrderInfo.setTop5Record(topOrderRecord);

			top20DeathNumRate += topOrderRecord.getDiagNumRate();
			i++;

		}

		topOrderRecord = new TopOrderRecord();
		topOrderRecord.setTopOrder("合计");
		topOrderRecord.setDiagNum(top20Total);
		// topOrderRecord.setDiagNumRate(NumUtil.round(NumUtil.div(top20Total,
		// deathTotalNum, 4) * 100, 2));
		topOrderRecord.setDiagNumRate(NumUtil.round(top20DeathNumRate, 2));
		topOrderRecord.setDeathNum(top20DeathNum);
		topOrderRecordList.add(topOrderRecord);

		diagTop20OrderInfo.setTotalOutNum(deathTotalNum);
		diagTop20OrderInfo.setTop20TotalOutNum(top20DeathNum);
		// diagTop20OrderInfo.setTop20TotalOutNumRate(NumUtil.round(NumUtil.div(top20Total,
		// deathTotalNum, 4) * 100, 2));
		diagTop20OrderInfo.setTop20TotalOutNumRate(NumUtil.round(top20DeathNumRate, 2));
		diagTop20OrderInfo.setTop20diagOrderRecords(topOrderRecordList);

		return diagTop20OrderInfo;
	}

	@Transactional(readOnly = true)
	@Override
	public DiagTop10DeptInfo getDiagOrderTop10ByDept(StatisticalReportParam statisticalReportParam, String orgCode) {

		String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		//DiagTop10DeptInfo diagTop10DeptInfo = this.getSubDiagOrderTop10ByDept(startTime1, endTime1, orgCode);
		DiagTop10DeptInfo diagTop10DeptInfo = this.getNewSubDiagOrderTop10ByDept(startTime1, endTime1, orgCode);
		
		
		String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
		String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
		//DiagTop10DeptInfo preMonthDiagTop10DeptInfo = this.getSubDiagOrderTop10ByDept(startTime2, endTime2, orgCode);
		DiagTop10DeptInfo preMonthDiagTop10DeptInfo = this.getNewSubDiagOrderTop10ByDept(startTime2, endTime2, orgCode);
		diagTop10DeptInfo.setPreMonthDiagTop10DeptRecord(preMonthDiagTop10DeptInfo.getDiagTop10DeptRecord());

		String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
		String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());
		//DiagTop10DeptInfo lastYearMonthDiagTop10DeptInfo = this.getSubDiagOrderTop10ByDept(startTime3, endTime3,orgCode);
		DiagTop10DeptInfo lastYearMonthDiagTop10DeptInfo = this.getNewSubDiagOrderTop10ByDept(startTime3, endTime3, orgCode);	
				
		diagTop10DeptInfo.setLastYearDiagTop10DeptRecord(lastYearMonthDiagTop10DeptInfo.getDiagTop10DeptRecord());

		List<DiagTop10DeptRecord> operationRecordList1 = diagTop10DeptInfo.getDiagTop10DeptRecord();

		List<DiagTop10DeptRecord> operationRecordList2 = diagTop10DeptInfo.getPreMonthDiagTop10DeptRecord();

		List<DiagTop10DeptRecord> operationRecordList3 = diagTop10DeptInfo.getLastYearDiagTop10DeptRecord();

		List<DiagTop20DTO> diagTop20DTOList = new LinkedList<DiagTop20DTO>();

		DiagTop20DTO diagTop20DTO = null;

		
		int index = 0;
		for (DiagTop10DeptRecord record1 : operationRecordList1) {
			diagTop20DTO = new DiagTop20DTO();

			String deptName = record1.getDeptName();
			diagTop20DTO.setDeptName(deptName);
			//从表4开始
			diagTop20DTO.setNum(4 + index);
			index++;
			List<TopOrderRecord> topOrderRecordList = record1.getDiagTop20OrderRecords();

			List<TopOrderRecord> preMonthTopOrderRecordList = null;

			List<TopOrderRecord> lastYearTopOrderRecordList = null;

			for (DiagTop10DeptRecord diagTop10DeptRecord : operationRecordList2) {
				if (deptName.equals(diagTop10DeptRecord.getDeptName())) {
					preMonthTopOrderRecordList = diagTop10DeptRecord.getDiagTop20OrderRecords();
				}
			}

			for (DiagTop10DeptRecord diagTop10DeptRecord : operationRecordList3) {
				if (deptName.equals(diagTop10DeptRecord.getDeptName())) {
					lastYearTopOrderRecordList = diagTop10DeptRecord.getDiagTop20OrderRecords();
				}
			}

			List<Top20DTO> top20DTOList = new LinkedList<Top20DTO>();
			int length = 0;
			int size = topOrderRecordList.size();
			int preMonthSize = preMonthTopOrderRecordList.size();
			int lastYearSize = lastYearTopOrderRecordList.size();
			if (size == preMonthSize && size == lastYearSize) {
				length = size;
			} else if (size >= preMonthSize && size >= lastYearSize) {
				length = size;
			} else if (preMonthSize >= size && preMonthSize >= lastYearSize) {
				length = preMonthSize;
			} else if (lastYearSize >= size && lastYearSize >= preMonthSize) {
				length = lastYearSize;
			}
			Top20DTO top20DTO = null;
			for (int i = 0; i < length; i++) {
				top20DTO = new Top20DTO();
				if (i <= (size - 1)) {

					TopOrderRecord topOrderRecord = topOrderRecordList.get(i);
					top20DTO.setTopOrder(topOrderRecord.getTopOrder());
					top20DTO.setDiagCode1(topOrderRecord.getDiagCode());
					top20DTO.setDiagName1(topOrderRecord.getDiagName());
					top20DTO.setDiagNum1(topOrderRecord.getDiagNum());
					top20DTO.setAvgInHospDays1(topOrderRecord.getAvgInHospDays());
					top20DTO.setAvgCostFee1(topOrderRecord.getAvgCostFee());

				}

				if (!CollectionUtils.isEmpty(preMonthTopOrderRecordList)) {
					if (i <= (preMonthSize - 1)) {
						TopOrderRecord preMonthTopOrderRecord = preMonthTopOrderRecordList.get(i);
						if (top20DTO.getTopOrder() == null) {
							top20DTO.setTopOrder(preMonthTopOrderRecord.getTopOrder());
						}

						top20DTO.setDiagCode2(preMonthTopOrderRecord.getDiagCode());
						top20DTO.setDiagName2(preMonthTopOrderRecord.getDiagName());
						top20DTO.setDiagNum2(preMonthTopOrderRecord.getDiagNum());
						top20DTO.setAvgInHospDays2(preMonthTopOrderRecord.getAvgInHospDays());
						top20DTO.setAvgCostFee2(preMonthTopOrderRecord.getAvgCostFee());
					}

				}

				if (!CollectionUtils.isEmpty(lastYearTopOrderRecordList)) {
					if (i <= (lastYearSize - 1)) {
						TopOrderRecord lastYearTopOrderRecord = lastYearTopOrderRecordList.get(i);
						if (top20DTO.getTopOrder() == null) {
							top20DTO.setTopOrder(lastYearTopOrderRecord.getTopOrder());
						}
						top20DTO.setDiagCode3(lastYearTopOrderRecord.getDiagCode());
						top20DTO.setDiagName3(lastYearTopOrderRecord.getDiagName());
						top20DTO.setDiagNum3(lastYearTopOrderRecord.getDiagNum());
						top20DTO.setAvgInHospDays3(lastYearTopOrderRecord.getAvgInHospDays());
						top20DTO.setAvgCostFee3(lastYearTopOrderRecord.getAvgCostFee());
					}

				}

				top20DTOList.add(top20DTO);

			}
			diagTop20DTO.setList(top20DTOList);
			diagTop20DTOList.add(diagTop20DTO);


		}
		
		diagTop10DeptInfo.setDiagTop20DTOList(diagTop20DTOList);

		return diagTop10DeptInfo;

	}
	
	
	
	public DiagTop10DeptInfo getNewSubDiagOrderTop10ByDept(String startTime, String endTime, String orgCode) {


		DiagTop10DeptInfo diagTop10DeptInfo = new DiagTop10DeptInfo();
		try {

			Map<String, List<String>> deptCodesMap = Constant.DEPT_CODES_MAP;

			List<DiagTop10DeptRecord> diagTop10DeptRecords = new ArrayList<>();
			DiagTop10DeptRecord diagTop10DeptRecord = null;
			TopOrderRecord diagTop20OrderRecord = null;
			for (Entry<String, List<String>> m : deptCodesMap.entrySet()) {
				diagTop10DeptRecord = new DiagTop10DeptRecord();
				diagTop10DeptRecord.setDeptName(m.getKey());
				List<String> deptCodes = m.getValue();
				
				String deptCodeStr = StringUtils.join(deptCodes.toArray(), ",");
				
				List<TopOrderRecord> diagTop20OrderRecords = new LinkedList<>();
				/**
				 * 按照亚目查询疾病统计信息
				 */
				List<QualityRecord> qualityRecordList = this.getQualityList(startTime,endTime,orgCode,deptCodeStr,"200","5");
				
				if(CollectionUtils.isEmpty(qualityRecordList)) {
					continue;
				}
				
				int deptCodeTotalNum = 0;
				for (QualityRecord qualityRecord : qualityRecordList) {
					deptCodeTotalNum += qualityRecord.getDischarges();
				}

				int i = 1;
				for (QualityRecord qualityRecord : qualityRecordList) {
					diagTop20OrderRecord = new TopOrderRecord();
					if(i>10) {
						continue;
					}

						String code = qualityRecord.getSpecies();
						diagTop20OrderRecord.setDiagCode(code);
						




						diagTop20OrderRecord.setTopOrder(i + "");

						diagTop20OrderRecord.setDiagName(qualityRecord.getSpeciesN());
						diagTop20OrderRecord.setDiagNum(qualityRecord.getDischarges());
						diagTop20OrderRecord.setAvgCostFee(new BigDecimal(qualityRecord.getCostPer()).setScale(2, BigDecimal.ROUND_HALF_UP));
						diagTop20OrderRecord.setDeathNum(qualityRecord.getDeaths());
						diagTop20OrderRecord.setAvgInHospDays(new BigDecimal(qualityRecord.getAverageStay()).setScale(2, BigDecimal.ROUND_HALF_UP));
					
						diagTop20OrderRecord.setDiagNumRate(
							 NumUtil.round(NumUtil.div(qualityRecord.getDischarges(), deptCodeTotalNum, 4) * 100, 2));
					 

						diagTop20OrderRecords.add(diagTop20OrderRecord);
						i++;

				}

				diagTop10DeptRecord.setDiagTop20OrderRecords(diagTop20OrderRecords);
				diagTop10DeptRecords.add(diagTop10DeptRecord);
			}

			diagTop10DeptInfo.setDiagTop10DeptRecord(diagTop10DeptRecords);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return diagTop10DeptInfo;

	}
	
	
	
	
	/**
	 * 调用现有接口统计信息
	 * @param startTime
	 * 				出院查询开始时间
	 * @param endTime
	 * 				出院查询结束时间
	 * @param orgCode
	 * 				组织机构代码
	 * @param deptCodeStr
	 * 				科室code  多科室以,连接
	 * @param limit
	 * 				每页显示调试
	 * @param length
	 * 				疾病编码长度   长度3类目  长度5亚目
	 * @return
	 */
	private List<QualityRecord> getQualityList(String startTime, String endTime, String orgCode, String deptCodeStr,String limit,String length) {

		Map<String, String> params = new HashMap<>();
		params.put("orgcode", orgCode);
		params.put("start", startTime);
		params.put("end", endTime);
		params.put("outDepaId", deptCodeStr);
		params.put("branchId", null);
		params.put("length", length);
		params.put("limit", limit);
		params.put("leader", null);
		params.put("cardid", null);
		params.put("jumpParam", "disease");
		params.put("sort","discharges");
		String json = HttpClientUtil.doPost("http://11.0.0.55:8999/medicalQuality/indicators", params);		
		QualityInfo qualityInfo = JsonUtil.jsonToPojo(json, QualityInfo.class);
		if(qualityInfo!=null) {
			return qualityInfo.getQualityList();
		}
		return null;
	}

	public DiagTop10DeptInfo getSubDiagOrderTop10ByDept(String startTime, String endTime, String orgCode) {

		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);

		DiagTop10DeptInfo diagTop10DeptInfo = new DiagTop10DeptInfo();
		try {

			Map<String, List<String>> deptCodesMap = Constant.DEPT_CODES_MAP;

			List<DiagTop10DeptRecord> diagTop10DeptRecords = new ArrayList<>();
			DiagTop10DeptRecord diagTop10DeptRecord = null;
			TopOrderRecord diagTop20OrderRecord = null;
			for (Entry<String, List<String>> m : deptCodesMap.entrySet()) {
				diagTop10DeptRecord = new DiagTop10DeptRecord();
				diagTop10DeptRecord.setDeptName(m.getKey());
				List<String> deptCodes = m.getValue();
				mrInBasicQuery.setDeptCodes(deptCodes);
				List<TopOrderRecord> diagTop20OrderRecords = new LinkedList<>();
				List<DiagRank> deptDiagRankList = mrInBasicMapper.getDiagRank(mrInBasicQuery);
				int deptCodeTotalNum = 0;
				for (DiagRank diagRank : deptDiagRankList) {
					deptCodeTotalNum += diagRank.getCodeNum();
				}

				int i = 1;
				for (DiagRank deptDiagRank : deptDiagRankList) {
					diagTop20OrderRecord = new TopOrderRecord();
					if (i <= 10) {

						String code = deptDiagRank.getCode();
						diagTop20OrderRecord.setDiagCode(code);
						String preCode = null;
						if (StringUtils.isBlank(code)) {
							continue;
						}
						if (code.contains(".x")) {
							preCode = code.substring(0, 3);
						} else {
							preCode = code.substring(0, 5);
						}

						List<String> diagNames = mrInBasicMapper.getDiagNameByCode(preCode);

						if (CollectionUtils.isEmpty(diagNames)) {
							diagNames = mrInBasicMapper.getDiagNameByCode(preCode + "+");
							// diagTop20OrderRecord.setDiagCode(preCode + "+");
						}
						deptDiagRank.setCodeName(CollectionUtils.isEmpty(diagNames) ? null : diagNames.get(0));

						diagTop20OrderRecord.setTopOrder(i + "");

						diagTop20OrderRecord.setDiagName(CollectionUtils.isEmpty(diagNames) ? null : diagNames.get(0));
						diagTop20OrderRecord.setDiagNum(deptDiagRank.getCodeNum());
						diagTop20OrderRecord.setAvgCostFee(deptDiagRank.getAvgFee());
						diagTop20OrderRecord.setDeathNum(deptDiagRank.getDeathNum());
						diagTop20OrderRecord.setAvgInHospDays(deptDiagRank.getAvgInHospDays());
						diagTop20OrderRecord.setDiagNumRate(
								NumUtil.round(NumUtil.div(deptDiagRank.getCodeNum(), deptCodeTotalNum, 4) * 100, 2));

						diagTop20OrderRecords.add(diagTop20OrderRecord);

					}
					i++;
				}

				diagTop10DeptRecord.setDiagTop20OrderRecords(diagTop20OrderRecords);
				diagTop10DeptRecords.add(diagTop10DeptRecord);
			}

			diagTop10DeptInfo.setDiagTop10DeptRecord(diagTop10DeptRecords);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return diagTop10DeptInfo;

	}

	@Transactional(readOnly = true)
	@Override
	public OperationTop20Info getOpsTop20Order(StatisticalReportParam statisticalReportParam, String orgCode) {

		String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		OperationTop20Info operationTop20Info = this.getSubOpsTop20Order(startTime1, endTime1, orgCode);

		String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
		String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
		OperationTop20Info preMonthOp20Info = this.getSubOpsTop20Order(startTime2, endTime2, orgCode);

		operationTop20Info.setPreMonthTopOrderRecords(preMonthOp20Info.getTopOrderRecords());

		String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
		String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());
		OperationTop20Info lastYearMonthOp20Info = this.getSubOpsTop20Order(startTime3, endTime3, orgCode);

		operationTop20Info.setLastYearTopOrderRecords(lastYearMonthOp20Info.getTopOrderRecords());
		
		List<Top20DTO> top20DTOList = new LinkedList<>();
		List<TopOrderRecord> list1 = operationTop20Info.getTopOrderRecords();
		List<TopOrderRecord> list2 = operationTop20Info.getPreMonthTopOrderRecords();
		List<TopOrderRecord> list3 = operationTop20Info.getLastYearTopOrderRecords();
		Top20DTO top20DTO = null;
		for (int i = 0; i < list1.size(); i++) {
			TopOrderRecord record1 = list1.get(i);
			TopOrderRecord record2 = list2.get(i);
			TopOrderRecord record3 = list3.get(i);
			top20DTO = new Top20DTO();

			top20DTO.setTopOrder(record1.getTopOrder() == null ? "" : record1.getTopOrder());
			top20DTO.setDiagCode1(record1.getDiagCode() == null ? "" : record1.getDiagCode());
			top20DTO.setDiagName1(record1.getDiagName() == null ? "" : record1.getDiagName());
			top20DTO.setDiagNum1(record1.getDiagNum());
			top20DTO.setAvgInHospDays1(record1.getAvgInHospDays());
			top20DTO.setAvgCostFee1(record1.getAvgCostFee());

			top20DTO.setDiagCode2(record2.getDiagCode());
			top20DTO.setDiagName2(record2.getDiagName());
			top20DTO.setDiagNum2(record2.getDiagNum());
			top20DTO.setAvgInHospDays2(record2.getAvgInHospDays());
			top20DTO.setAvgCostFee2(record2.getAvgCostFee());

			top20DTO.setDiagCode3(record3.getDiagCode());
			top20DTO.setDiagName3(record3.getDiagName());
			top20DTO.setDiagNum3(record3.getDiagNum());
			top20DTO.setAvgInHospDays3(record3.getAvgInHospDays());
			top20DTO.setAvgCostFee3(record3.getAvgCostFee());

			if (record1.getTopOrder().equals("合计")) {
				top20DTO.setTopOrder("");
				top20DTO.setDiagCode1("合计");
			}

			System.out.println(top20DTO);

			top20DTOList.add(top20DTO);
		}
		
		operationTop20Info.setTop20DTOList(top20DTOList);

		return operationTop20Info;
	}

	public OperationTop20Info getSubOpsTop20Order(String startTime, String endTime, String orgCode) {
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);
		//设置查询手术编码为类目
		mrInBasicQuery.setOpCodeLength(2);
		OperationTop20Info operationTop20Info = new OperationTop20Info();
		// 查询当前出院时间所有的疾病编码
		List<OperationRank> operationRankList = mrInBasicMapper.getOperationRank(mrInBasicQuery);
		Integer totalCodeNum = 0;
		for (OperationRank operationRank : operationRankList) {
			totalCodeNum += operationRank.getNum();

		}

		List<TopOrderRecord> topOrderRecords = new LinkedList<>();
		TopOrderRecord topOrderRecord = null;
		// 手术前20手术顺位
		int top20OpsCount = 0;
		int top20DeathCount = 0;
		int index = 1;
		for (OperationRank operationRank : operationRankList) {
			topOrderRecord = new TopOrderRecord();
			if (index <= 20) {
				String code = operationRank.getOpCode();
				topOrderRecord.setDiagCode(code);
//				if (code.contains("x")) {
//					preCode = code.substring(0, 4);
//				} else {
//					preCode = code.substring(0, 5);
//				}
				List<String> opsNames = mrInBasicMapper.getOpsNameByCode(code);

//				if (CollectionUtils.isEmpty(opsNames)) {
//					preCode = preCode + "+";
//					opsNames = mrInBasicMapper.getOpsNameByCode(preCode);
//					topOrderRecord.setDiagCode(preCode + "+");
//				}

				topOrderRecord.setTopOrder(index + "");

				topOrderRecord.setDiagNum(operationRank.getNum());
				topOrderRecord.setDiagName(CollectionUtils.isEmpty(opsNames) ? null : opsNames.get(0));
				topOrderRecord
						.setDiagNumRate(NumUtil.round(NumUtil.div(operationRank.getNum(), totalCodeNum, 4) * 100, 2));
				topOrderRecord.setDeathNum(operationRank.getDeathNum());
				topOrderRecord.setAvgCostFee(operationRank.getAvgFee());
				topOrderRecord.setAvgInHospDays(operationRank.getAvgInHospDays());
				topOrderRecords.add(topOrderRecord);
				top20OpsCount += operationRank.getNum();
				top20DeathCount += operationRank.getDeathNum();
				if (index == 1)
					operationTop20Info.setTop1OpsOrder(topOrderRecord);
				if (index == 2)
					operationTop20Info.setTop2OpsOrder(topOrderRecord);
				if (index == 3)
					operationTop20Info.setTop3OpsOrder(topOrderRecord);
				if (index == 4)
					operationTop20Info.setTop4OpsOrder(topOrderRecord);
				if (index == 5)
					operationTop20Info.setTop5OpsOrder(topOrderRecord);
			}
			index++;
		}

		topOrderRecord = new TopOrderRecord();
		topOrderRecord.setTopOrder("合计");
		topOrderRecord.setDiagNum(top20OpsCount);
		topOrderRecord.setDeathNum(top20DeathCount);
		topOrderRecord
				.setDiagNumRate(NumUtil.round(NumUtil.div(Double.valueOf(top20OpsCount), totalCodeNum, 4) * 100, 2));
		topOrderRecords.add(topOrderRecord);
		operationTop20Info.setTopOrderRecords(topOrderRecords);
		operationTop20Info.setOpsTotalCount(totalCodeNum);
		operationTop20Info.setOpsTop20TotalCount(top20OpsCount);
		operationTop20Info
				.setOpsTop20Rate(NumUtil.round(NumUtil.div(Double.valueOf(top20OpsCount), totalCodeNum, 4) * 100, 2));

		return operationTop20Info;
	}

	@Override
	public DiagTop10DeptInfo getOpsTop10DeptOrder(StatisticalReportParam statisticalReportParam, String orgCode) {

		String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		DiagTop10DeptInfo diagTop10DeptInfo = this.getSubOpsTop10DeptOrder(startTime1, endTime1, orgCode);

		String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
		String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
		DiagTop10DeptInfo diagTop10DeptInfo2 = this.getSubOpsTop10DeptOrder(startTime2, endTime2, orgCode);

		String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
		String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());
		DiagTop10DeptInfo diagTop10DeptInfo3 = this.getSubOpsTop10DeptOrder(startTime3, endTime3, orgCode);

		diagTop10DeptInfo.setPreMonthDiagTop10DeptRecord(diagTop10DeptInfo2.getDiagTop10DeptRecord());
		diagTop10DeptInfo.setLastYearDiagTop10DeptRecord(diagTop10DeptInfo3.getDiagTop10DeptRecord());
		
		List<DiagTop10DeptRecord> operationRecordList1 = diagTop10DeptInfo.getDiagTop10DeptRecord();

		List<DiagTop10DeptRecord> operationRecordList2 = diagTop10DeptInfo.getPreMonthDiagTop10DeptRecord();

		List<DiagTop10DeptRecord> operationRecordList3 = diagTop10DeptInfo.getLastYearDiagTop10DeptRecord();

		List<DiagTop20DTO> diagTop20DTOList = new LinkedList<DiagTop20DTO>();

		DiagTop20DTO diagTop20DTO = null;

		try {

			int index = 0;
			for (DiagTop10DeptRecord record1 : operationRecordList1) {
				diagTop20DTO = new DiagTop20DTO();

				String deptName = record1.getDeptName();
				diagTop20DTO.setDeptName(deptName);
				diagTop20DTO.setNum(41 + index);
				index++;
				List<TopOrderRecord> topOrderRecordList = record1.getDiagTop20OrderRecords();

				List<TopOrderRecord> preMonthTopOrderRecordList = null;

				List<TopOrderRecord> lastYearTopOrderRecordList = null;

				for (DiagTop10DeptRecord diagTop10DeptRecord : operationRecordList2) {
					if (deptName.equals(diagTop10DeptRecord.getDeptName())) {
						preMonthTopOrderRecordList = diagTop10DeptRecord.getDiagTop20OrderRecords();
					}
				}

				for (DiagTop10DeptRecord diagTop10DeptRecord : operationRecordList3) {
					if (deptName.equals(diagTop10DeptRecord.getDeptName())) {
						lastYearTopOrderRecordList = diagTop10DeptRecord.getDiagTop20OrderRecords();
					}
				}

				List<Top20DTO> top20DTOList = new LinkedList<Top20DTO>();
				int length = 0;
				int size = topOrderRecordList.size();
				int preMonthSize = preMonthTopOrderRecordList.size();
				int lastYearSize = lastYearTopOrderRecordList.size();
				if (size == preMonthSize && size == lastYearSize) {
					length = size;
				} else if (size >= preMonthSize && size >= lastYearSize) {
					length = size;
				} else if (preMonthSize >= size && preMonthSize >= lastYearSize) {
					length = preMonthSize;
				} else if (lastYearSize >= size && lastYearSize >= preMonthSize) {
					length = lastYearSize;
				}
				Top20DTO top20DTO = null;
				for (int i = 0; i < length; i++) {
					top20DTO = new Top20DTO();
					if (i <= (size - 1)) {

						TopOrderRecord topOrderRecord = topOrderRecordList.get(i);
						top20DTO.setTopOrder(topOrderRecord.getTopOrder());
						top20DTO.setDiagCode1(topOrderRecord.getDiagCode());
						top20DTO.setDiagName1(topOrderRecord.getDiagName());
						top20DTO.setDiagNum1(topOrderRecord.getDiagNum());
						top20DTO.setAvgInHospDays1(topOrderRecord.getAvgInHospDays());
						top20DTO.setAvgCostFee1(topOrderRecord.getAvgCostFee());

					}

					if (!CollectionUtils.isEmpty(preMonthTopOrderRecordList)) {
						if (i <= (preMonthSize - 1)) {
							TopOrderRecord preMonthTopOrderRecord = preMonthTopOrderRecordList.get(i);
							if(top20DTO.getTopOrder()==null) {
								top20DTO.setTopOrder(preMonthTopOrderRecord.getTopOrder());
							}
							
						
							
							top20DTO.setDiagCode2(preMonthTopOrderRecord.getDiagCode());
							top20DTO.setDiagName2(preMonthTopOrderRecord.getDiagName());
							top20DTO.setDiagNum2(preMonthTopOrderRecord.getDiagNum());
							top20DTO.setAvgInHospDays2(preMonthTopOrderRecord.getAvgInHospDays());
							top20DTO.setAvgCostFee2(preMonthTopOrderRecord.getAvgCostFee());
						}

					}

					if (!CollectionUtils.isEmpty(lastYearTopOrderRecordList)) {
						if (i <= (lastYearSize - 1)) {
							TopOrderRecord lastYearTopOrderRecord = lastYearTopOrderRecordList.get(i);
							if(top20DTO.getTopOrder()==null) {
								top20DTO.setTopOrder(lastYearTopOrderRecord.getTopOrder());
							}
							top20DTO.setDiagCode3(lastYearTopOrderRecord.getDiagCode());
							top20DTO.setDiagName3(lastYearTopOrderRecord.getDiagName());
							top20DTO.setDiagNum3(lastYearTopOrderRecord.getDiagNum());
							top20DTO.setAvgInHospDays3(lastYearTopOrderRecord.getAvgInHospDays());
							top20DTO.setAvgCostFee3(lastYearTopOrderRecord.getAvgCostFee());
						}

					}

					top20DTOList.add(top20DTO);

				}
				diagTop20DTO.setList(top20DTOList);
				diagTop20DTOList.add(diagTop20DTO);

				System.out.println(diagTop20DTO);

			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		diagTop10DeptInfo.setDiagTop20DTOList(diagTop20DTOList);

		return diagTop10DeptInfo;
	}

	public DiagTop10DeptInfo getSubOpsTop10DeptOrder(String startTime, String endTime, String orgCode) {
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);
		//设置查询手术编码长度
		mrInBasicQuery.setOpCodeLength(5);
		Map<String, List<String>> deptCodesMap = Constant.OPS_DEPT_CODES_MAP;
		DiagTop10DeptInfo diagTop10DeptInfo = new DiagTop10DeptInfo();
		List<DiagTop10DeptRecord> diagTop10DeptRecords = new ArrayList<>();
		DiagTop10DeptRecord diagTop10DeptRecord = null;
		for (Entry<String, List<String>> m : deptCodesMap.entrySet()) {
			diagTop10DeptRecord = new DiagTop10DeptRecord();
			diagTop10DeptRecord.setDeptName(m.getKey());
			List<String> deptCodes = m.getValue();
			mrInBasicQuery.setDeptCodes(deptCodes);
			List<OperationRank> diagCodeList = mrInBasicMapper.getOperationRank(mrInBasicQuery);

			//List<OperationRank> newDiagCodeList = mrInBasicMapper.getOperationRank(mrInBasicQuery);
			Integer totalCodeNum = 0;
			for (OperationRank operationRank : diagCodeList) {
				totalCodeNum += operationRank.getNum();
			}

			int i = 1;
			List<TopOrderRecord> diagTop20OrderRecords = new LinkedList<>();
			TopOrderRecord diagTop20OrderRecord = null;
			for (OperationRank operationRank : diagCodeList) {
				if (i > 10)
					continue;
				diagTop20OrderRecord = new TopOrderRecord();
				String code = operationRank.getOpCode();
				diagTop20OrderRecord.setDiagCode(code);
				String preCode = null;
				if (code.contains("x")) {
					preCode = code.substring(0, 4);
				} else {
					preCode = code.substring(0, 5);
				}
				List<String> opsNames = mrInBasicMapper.getOpsNameByCode(preCode);

				if (CollectionUtils.isEmpty(opsNames)) {
					preCode = preCode + "+";
					opsNames = mrInBasicMapper.getOpsNameByCode(preCode);
				}

				diagTop20OrderRecord.setTopOrder(i + "");
				diagTop20OrderRecord.setAvgCostFee(operationRank.getAvgFee());
				diagTop20OrderRecord.setAvgInHospDays(operationRank.getAvgInHospDays());
				diagTop20OrderRecord.setDeathNum(operationRank.getDeathNum());
				diagTop20OrderRecord.setDiagNumRate(
						NumUtil.round(NumUtil.div(Double.valueOf(operationRank.getNum()), totalCodeNum, 4) * 100, 2));
				diagTop20OrderRecord.setDiagName(CollectionUtils.isEmpty(opsNames) ? null : opsNames.get(0));
				diagTop20OrderRecord.setDiagNum(operationRank.getNum());
				diagTop20OrderRecords.add(diagTop20OrderRecord);
				i++;

			}

			diagTop10DeptRecord.setDiagTop20OrderRecords(diagTop20OrderRecords);
			diagTop10DeptRecords.add(diagTop10DeptRecord);

		}
		diagTop10DeptInfo.setDiagTop10DeptRecord(diagTop10DeptRecords);
		return diagTop10DeptInfo;
	}

	@Transactional(readOnly = true)
	@Override
	public CostFeeInfo getCostFeeInfo(StatisticalReportParam statisticalReportParam, String orgCode) {

		CostFeeInfo costFeeInfo = new CostFeeInfo();
		try {
			String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
			String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
			// 获取本月费用信息
			CostFee costFee = getCostFee(startTime1, endTime1, orgCode);
			// 获取上月数据信息
			String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
			String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
			CostFee preMonthCostFee = getCostFee(startTime2, endTime2, orgCode);
			// 获取去年同期数据信息
			String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
			String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());
			CostFee lastYearMonthDateStrMonthCostFee = getCostFee(startTime3, endTime3, orgCode);
			BaseDataRecord preMonthTotalFeeRecord = geBaseDataRecord(costFee.getZfy(), preMonthCostFee.getZfy(),
					"totalFee");
			costFeeInfo.setPreMonthtotalFeeRecord(preMonthTotalFeeRecord);
			BaseDataRecord lastYearMonthtotalFeeRecord = geBaseDataRecord(costFee.getZfy(),
					lastYearMonthDateStrMonthCostFee.getZfy(), "totalFee");
			costFeeInfo.setLastYearMonthtotalFeeRecord(lastYearMonthtotalFeeRecord);
			BaseDataRecord preMonthAvgFeeRecord = geBaseDataRecord(costFee.getPingjunFeiyong(),
					preMonthCostFee.getPingjunFeiyong(), null);
			costFeeInfo.setPreMonthAvgFeeRecord(preMonthAvgFeeRecord);
			BaseDataRecord lastYearAvgFeeRecord = geBaseDataRecord(costFee.getPingjunFeiyong(),
					lastYearMonthDateStrMonthCostFee.getPingjunFeiyong(), null);
			costFeeInfo.setLastYearAvgFeeRecord(lastYearAvgFeeRecord);

			BaseDataRecord preMonthYzbFeeRecord = geBaseDataRecord(costFee.getYaozhanbi(),
					preMonthCostFee.getYaozhanbi(), "yzbFee");
			costFeeInfo.setPreMonthYzbFeeRecord(preMonthYzbFeeRecord);
			BaseDataRecord lastYearYzbFeeRecord = geBaseDataRecord(costFee.getYaozhanbi(),
					lastYearMonthDateStrMonthCostFee.getYaozhanbi(), "yzbFee");
			costFeeInfo.setLastYearYzbFeeRecord(lastYearYzbFeeRecord);

			BaseDataRecord preMonthHzbFeeRecord = geBaseDataRecord(costFee.getYcxhczb(), preMonthCostFee.getYcxhczb(),
					"yzbFee");
			costFeeInfo.setPreMonthHzbFeeRecord(preMonthHzbFeeRecord);
			BaseDataRecord lastYearHzbFeeRecord = geBaseDataRecord(costFee.getYcxhczb(),
					lastYearMonthDateStrMonthCostFee.getYcxhczb(), "yzbFee");
			costFeeInfo.setLastYearHzbFeeRecord(lastYearHzbFeeRecord);

			BaseDataRecord preMonthYHzbFeeRecord = geBaseDataRecord(costFee.getYcxhczb().add(costFee.getYaozhanbi()),
					preMonthCostFee.getYcxhczb().add(preMonthCostFee.getYaozhanbi()), "yzbFee");
			costFeeInfo.setPreMonthYHzbFeeRecord(preMonthYHzbFeeRecord);
			BaseDataRecord lastYearYHzbFeeRecord = geBaseDataRecord(costFee.getYcxhczb().add(costFee.getYaozhanbi()),
					lastYearMonthDateStrMonthCostFee.getYcxhczb().add(lastYearMonthDateStrMonthCostFee.getYaozhanbi()),
					"yzbFee");
			costFeeInfo.setLastYearYHzbFeeRecord(lastYearYHzbFeeRecord);

			CostFeeChartRecord costFeeChartRecord = new CostFeeChartRecord();
			List<String> monthList = new LinkedList<>();
			monthList.add(statisticalReportParam.getStatics1Name());
			monthList.add(statisticalReportParam.getStatics3Name());
			monthList.add(statisticalReportParam.getStatics2Name());
			costFeeChartRecord.setMonthList(monthList);
			
			
			List<Integer> avgFeeNumList = new ArrayList<>();

			List<BigDecimal> avgFeeList = new LinkedList<>();
			avgFeeList.add(preMonthAvgFeeRecord.getMonthNum());
			avgFeeNumList.add(preMonthAvgFeeRecord.getMonthNum()==null?0:preMonthAvgFeeRecord.getMonthNum().intValue());
			avgFeeList.add(lastYearAvgFeeRecord.getOtherMonthNum());
			avgFeeNumList.add(lastYearAvgFeeRecord.getOtherMonthNum()==null?0:lastYearAvgFeeRecord.getOtherMonthNum().intValue());
			avgFeeList.add(preMonthAvgFeeRecord.getOtherMonthNum());
			avgFeeNumList.add(preMonthAvgFeeRecord.getOtherMonthNum()==null?0:preMonthAvgFeeRecord.getOtherMonthNum().intValue());
			costFeeChartRecord.setAvgFeeList(avgFeeList);

			List<BigDecimal> yzbFeeList = new LinkedList<>();
			yzbFeeList.add(preMonthYzbFeeRecord.getMonthNum());
			yzbFeeList.add(lastYearYzbFeeRecord.getOtherMonthNum());
			yzbFeeList.add(preMonthYzbFeeRecord.getOtherMonthNum());
			costFeeChartRecord.setYabFeeList(yzbFeeList);

			List<BigDecimal> hzbFeeList = new LinkedList<>();
			hzbFeeList.add(preMonthHzbFeeRecord.getMonthNum());
			hzbFeeList.add(lastYearHzbFeeRecord.getOtherMonthNum());
			hzbFeeList.add(preMonthHzbFeeRecord.getOtherMonthNum());
			costFeeChartRecord.setHczbFeeList(hzbFeeList);
			
			
			
			int total1Num = Collections.max(avgFeeNumList);
			if(total1Num>0) {
				costFeeChartRecord.setHignNum(NumUtil.getTotalNum(total1Num));
				costFeeChartRecord.setAvgNum(NumUtil.getTotalNum(total1Num)/10);
				
			}else {
				costFeeChartRecord.setHignNum(30000);
				costFeeChartRecord.setAvgNum(10000);
			}

			costFeeInfo.setCostFeeChartRecord(costFeeChartRecord);

		} catch (Exception e) {
			e.printStackTrace();
		}

		return costFeeInfo;
	}

	@Transactional(readOnly = true)
	@Override
	public OpNumberInfo getOpNumberInfo(StatisticalReportParam statisticalReportParam, String orgCode) {
		OpNumberInfo opNumberInfo = new OpNumberInfo();
		try {
			// 当月数据
			String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
			String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
			OperationNumber monthOpNumber = getOperationNumber(startTime1, endTime1, orgCode);
			// 上月数据
			String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
			String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
			OperationNumber preMonthOpNumber = getOperationNumber(startTime2, endTime2, orgCode);
			// 去年同月数据
			String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
			String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());
			OperationNumber lastYearMonthOpNumber = getOperationNumber(startTime3, endTime3, orgCode);
			// 去年同月手术及操作人次数对比
			BaseDataRecord lastYearOpHandleRecord = geBaseDataRecord(monthOpNumber.getOpNum(),
					lastYearMonthOpNumber.getOpNum(), "people");
			opNumberInfo.setLastYearOpHandleNumberRecord(lastYearOpHandleRecord);
			// 上月手术及操作人次数对比
			BaseDataRecord preMonthOpHandleRecord = geBaseDataRecord(monthOpNumber.getOpNum(),
					preMonthOpNumber.getOpNum(), "people");
			opNumberInfo.setPreMonthOpHandleNumberRecord(preMonthOpHandleRecord);
			// 去年手术及治疗性操作人次数对比
			BaseDataRecord lastYearOpCureNumberRecord = geBaseDataRecord(monthOpNumber.getTherapeOpNum(),
					lastYearMonthOpNumber.getTherapeOpNum(), "people");
			opNumberInfo.setLastYearOpCureNumberRecord(lastYearOpCureNumberRecord);
			// 上月手术及治疗性操作人次数对比
			BaseDataRecord preMonthOpCureNumberRecord = geBaseDataRecord(monthOpNumber.getTherapeOpNum(),
					preMonthOpNumber.getTherapeOpNum(), "people");
			opNumberInfo.setPreMonthOpCureNumberRecord(preMonthOpCureNumberRecord);

			// 去年三四级手术及治疗性操作人次数对比
			BaseDataRecord lastYearThirdForthNumberRecord = geBaseDataRecord(monthOpNumber.getThirdFourthLevelOpNum(),
					lastYearMonthOpNumber.getThirdFourthLevelOpNum(), "people");
			opNumberInfo.setLastYearThirdForthNumberRecord(lastYearThirdForthNumberRecord);
			// 上月三四级手术及治疗性操作人次数对比
			BaseDataRecord preMonthThirdForthNumberRecord = geBaseDataRecord(monthOpNumber.getThirdFourthLevelOpNum(),
					preMonthOpNumber.getThirdFourthLevelOpNum(), "people");
			opNumberInfo.setPreMonthThirdForthNumberRecord(preMonthThirdForthNumberRecord);

			// 去年手术占比对比
			BaseDataRecord lastYearOpRatioRecord = geBaseDataRecord(
					BigDecimalUtil.getDivideRate(monthOpNumber.getOperationNum(), monthOpNumber.getOutNum()),
					BigDecimalUtil.getDivideRate(lastYearMonthOpNumber.getOperationNum(),
							lastYearMonthOpNumber.getOutNum()),
					null);
			opNumberInfo.setLastYearOpRatioRecord(lastYearOpRatioRecord);
			// 上月手术占比对比
			BaseDataRecord preMonthOpRatioRecord = geBaseDataRecord(
					BigDecimalUtil.getDivideRate(monthOpNumber.getOperationNum(), monthOpNumber.getOutNum()),
					BigDecimalUtil.getDivideRate(preMonthOpNumber.getOperationNum(), preMonthOpNumber.getOutNum()),
					null);
			opNumberInfo.setPreMonthOpRatioRecord(preMonthOpRatioRecord);

			// 去年三四级手术及治疗性操作占比对比
			BaseDataRecord lastYearThirdForthRatioRecord = geBaseDataRecord(
					BigDecimalUtil.getDivideRate(monthOpNumber.getThirdFourthLevelOpNum(),
							monthOpNumber.getTherapeOpNum()),
					BigDecimalUtil.getDivideRate(lastYearMonthOpNumber.getThirdFourthLevelOpNum(),
							lastYearMonthOpNumber.getTherapeOpNum()),
					null);
			opNumberInfo.setLastYearThirdForthRatioRecord(lastYearThirdForthRatioRecord);
			// 上月三四级手术及治疗性操作占比对比
			BaseDataRecord preMonthThirdForthRatioRecord = geBaseDataRecord(
					BigDecimalUtil.getDivideRate(monthOpNumber.getThirdFourthLevelOpNum(),
							monthOpNumber.getTherapeOpNum()),
					BigDecimalUtil.getDivideRate(preMonthOpNumber.getThirdFourthLevelOpNum(),
							preMonthOpNumber.getTherapeOpNum()),
					null);
			opNumberInfo.setPreMonthThirdForthRatioRecord(preMonthThirdForthRatioRecord);

			// 去年节假日手术及治疗性操作人次数对比
			BaseDataRecord lastYearHolidayOpCureHandleNumberRecord = geBaseDataRecord(
					monthOpNumber.getHolidayTherapeOpNum(), lastYearMonthOpNumber.getHolidayTherapeOpNum(), "people");
			opNumberInfo.setLastYearHolidayOpCureHandleNumberRecord(lastYearHolidayOpCureHandleNumberRecord);
			// 上月节假日手术及治疗性操作人次数对比
			BaseDataRecord preMonthHolidayOpCureHandleNumberRecord = geBaseDataRecord(
					monthOpNumber.getHolidayTherapeOpNum(), preMonthOpNumber.getHolidayTherapeOpNum(), "people");
			opNumberInfo.setPreMonthHolidayOpCureHandleNumberRecord(preMonthHolidayOpCureHandleNumberRecord);

			// 去年节假日手术治疗人次数对比
			BaseDataRecord lastYearHolidayOpCureNumberRecord = geBaseDataRecord(monthOpNumber.getHolidaySurgicalNum(),
					lastYearMonthOpNumber.getHolidaySurgicalNum(), "people");
			opNumberInfo.setLastYearHolidayOpCureNumberRecord(lastYearHolidayOpCureNumberRecord);
			// 上月节假日手术治疗人次数对比
			BaseDataRecord preMonthHolidayOpCureNumberRecord = geBaseDataRecord(monthOpNumber.getHolidaySurgicalNum(),
					preMonthOpNumber.getHolidaySurgicalNum(), "people");
			opNumberInfo.setPreMonthHolidayOpCureNumberRecord(preMonthHolidayOpCureNumberRecord);

			// 去年节假日治疗性操作人次数对比
			BaseDataRecord lastYearHolidayCureNumberRecord = geBaseDataRecord(
					monthOpNumber.getHolidayTherapeManipulationNum(),
					lastYearMonthOpNumber.getHolidayTherapeManipulationNum(), "people");
			opNumberInfo.setLastYearHolidayCureNumberRecord(lastYearHolidayCureNumberRecord);
			// 上月节假日治疗性操作人次数对比
			BaseDataRecord preMonthHolidayCureNumberRecord = geBaseDataRecord(
					monthOpNumber.getHolidayTherapeManipulationNum(),
					preMonthOpNumber.getHolidayTherapeManipulationNum(), "people");
			opNumberInfo.setPreMonthHolidayCureNumberRecord(preMonthHolidayCureNumberRecord);

			// 去年节假日诊断性操作人次数对比
			BaseDataRecord lastYearHolidayDiagHandleNumberRecord = geBaseDataRecord(monthOpNumber.getHolidayDiagOpNum(),
					lastYearMonthOpNumber.getHolidayDiagOpNum(), "people");
			opNumberInfo.setLastYearHolidayDiagHandleNumberRecord(lastYearHolidayDiagHandleNumberRecord);
			// 上月节假日诊断性操作人次数对比
			BaseDataRecord preMonthholidayDiagHandleNumberRecord = geBaseDataRecord(monthOpNumber.getHolidayDiagOpNum(),
					preMonthOpNumber.getHolidayDiagOpNum(), "people");
			opNumberInfo.setPreMonthholidayDiagHandleNumberRecord(preMonthholidayDiagHandleNumberRecord);

			EchartsBaseRecord echartsBaseRecord1 = new EchartsBaseRecord();
			
			List<String> monthList = new LinkedList<>();
			monthList.add(statisticalReportParam.getStatics1Name());
			monthList.add(statisticalReportParam.getStatics3Name());
			monthList.add(statisticalReportParam.getStatics2Name());
			echartsBaseRecord1.setMonthList(monthList);

			List<Integer> total1NumList = new ArrayList<>();
			
			List<BigDecimal> monthOpList = new LinkedList<>();
			monthOpList.add(monthOpNumber.getOpNum());
			total1NumList.add(monthOpNumber.getOpNum()==null?0:monthOpNumber.getOpNum().intValue());
			monthOpList.add(monthOpNumber.getTherapeOpNum());
			total1NumList.add(monthOpNumber.getTherapeOpNum()==null?0:monthOpNumber.getTherapeOpNum().intValue());
			monthOpList.add(monthOpNumber.getThirdFourthLevelOpNum());
			total1NumList.add(monthOpNumber.getThirdFourthLevelOpNum()==null?0:monthOpNumber.getThirdFourthLevelOpNum().intValue());
			echartsBaseRecord1.setData1List(monthOpList);

			List<BigDecimal> monthOpCureList = new LinkedList<>();

			monthOpCureList.add(lastYearMonthOpNumber.getOpNum());
			total1NumList.add(lastYearMonthOpNumber.getOpNum()==null?0:lastYearMonthOpNumber.getOpNum().intValue());
			monthOpCureList.add(lastYearMonthOpNumber.getTherapeOpNum());
			total1NumList.add(lastYearMonthOpNumber.getTherapeOpNum()==null?0:lastYearMonthOpNumber.getTherapeOpNum().intValue());
			monthOpCureList.add(lastYearMonthOpNumber.getThirdFourthLevelOpNum());
			total1NumList.add(lastYearMonthOpNumber.getThirdFourthLevelOpNum()==null?0:lastYearMonthOpNumber.getThirdFourthLevelOpNum().intValue());
			echartsBaseRecord1.setData2List(monthOpCureList);

			List<BigDecimal> thirdForthList = new LinkedList<>();

			thirdForthList.add(preMonthOpNumber.getOpNum());
			total1NumList.add(preMonthOpNumber.getOpNum()==null?0:preMonthOpNumber.getOpNum().intValue());
			thirdForthList.add(preMonthOpNumber.getTherapeOpNum());
			total1NumList.add(preMonthOpNumber.getTherapeOpNum()==null?0:preMonthOpNumber.getTherapeOpNum().intValue());
			thirdForthList.add(preMonthOpNumber.getThirdFourthLevelOpNum());
			total1NumList.add(preMonthOpNumber.getThirdFourthLevelOpNum()==null?0:preMonthOpNumber.getThirdFourthLevelOpNum().intValue());
			echartsBaseRecord1.setData3List(thirdForthList);

			opNumberInfo.setEchartsBaseRecord1(echartsBaseRecord1);
			
			int total1Num = Collections.max(total1NumList);
			if(total1Num>0) {
				echartsBaseRecord1.setTotalNum(NumUtil.getTotalNum(total1Num));
				echartsBaseRecord1.setAvgNum(NumUtil.getTotalNum(total1Num)/10);
				
			}else {
				echartsBaseRecord1.setTotalNum(10000);
				echartsBaseRecord1.setAvgNum(2000);
			}

			// 住院患者手术率统计指标
			EchartsBaseRecord echartsBaseRecord2 = new EchartsBaseRecord();

			echartsBaseRecord2.setMonthList(monthList);

			List<BigDecimal> monthOpRatioList = new LinkedList<>();
			monthOpRatioList.add(lastYearOpRatioRecord.getMonthNum());
			monthOpRatioList.add(lastYearOpRatioRecord.getOtherMonthNum());
			monthOpRatioList.add(preMonthOpRatioRecord.getOtherMonthNum());
			echartsBaseRecord2.setData1List(monthOpRatioList);

			List<BigDecimal> lastYearOpRatioList = new LinkedList<>();
			lastYearOpRatioList.add(lastYearThirdForthRatioRecord.getMonthNum());
			lastYearOpRatioList.add(lastYearThirdForthRatioRecord.getOtherMonthNum());
			lastYearOpRatioList.add(preMonthThirdForthRatioRecord.getOtherMonthNum());
			echartsBaseRecord2.setData2List(lastYearOpRatioList);

			opNumberInfo.setEchartsBaseRecord2(echartsBaseRecord2);

			EchartsBaseRecord echartsBaseRecord3 = new EchartsBaseRecord();
			
			List<Integer> total2NumList = new ArrayList<>();
			echartsBaseRecord3.setMonthList(monthList);
			List<BigDecimal> list1 = new LinkedList<>();
			list1.add(lastYearHolidayOpCureHandleNumberRecord.getMonthNum());
			total2NumList.add(lastYearHolidayOpCureHandleNumberRecord.getMonthNum()==null?0:lastYearHolidayOpCureHandleNumberRecord.getMonthNum().intValue());
			list1.add(lastYearHolidayOpCureNumberRecord.getMonthNum());
			total2NumList.add(lastYearHolidayOpCureNumberRecord.getMonthNum()==null?0:lastYearHolidayOpCureNumberRecord.getMonthNum().intValue());
			list1.add(lastYearHolidayCureNumberRecord.getMonthNum());
			total2NumList.add(lastYearHolidayCureNumberRecord.getMonthNum()==null?0:lastYearHolidayCureNumberRecord.getMonthNum().intValue());
			list1.add(lastYearHolidayDiagHandleNumberRecord.getMonthNum());
			total2NumList.add(lastYearHolidayDiagHandleNumberRecord.getMonthNum()==null?0:lastYearHolidayDiagHandleNumberRecord.getMonthNum().intValue());
			echartsBaseRecord3.setData1List(list1);

			List<BigDecimal> list2 = new LinkedList<>();
			list2.add(lastYearHolidayOpCureHandleNumberRecord.getOtherMonthNum());
			total2NumList.add(lastYearHolidayOpCureHandleNumberRecord.getOtherMonthNum()==null?0:lastYearHolidayOpCureHandleNumberRecord.getOtherMonthNum().intValue());
			list2.add(lastYearHolidayOpCureNumberRecord.getOtherMonthNum());
			total2NumList.add(lastYearHolidayOpCureNumberRecord.getOtherMonthNum()==null?0:lastYearHolidayOpCureNumberRecord.getOtherMonthNum().intValue());
			list2.add(lastYearHolidayCureNumberRecord.getOtherMonthNum());
			total2NumList.add(lastYearHolidayCureNumberRecord.getOtherMonthNum()==null?0:lastYearHolidayCureNumberRecord.getOtherMonthNum().intValue());
			list2.add(lastYearHolidayDiagHandleNumberRecord.getOtherMonthNum());
			total2NumList.add(lastYearHolidayDiagHandleNumberRecord.getOtherMonthNum()==null?0:lastYearHolidayDiagHandleNumberRecord.getOtherMonthNum().intValue());
			echartsBaseRecord3.setData2List(list2);

			List<BigDecimal> list3 = new LinkedList<>();
			list3.add(preMonthHolidayOpCureHandleNumberRecord.getOtherMonthNum());
			total2NumList.add(preMonthHolidayOpCureHandleNumberRecord.getOtherMonthNum()==null?0:preMonthHolidayOpCureHandleNumberRecord.getOtherMonthNum().intValue());
			list3.add(preMonthHolidayOpCureNumberRecord.getOtherMonthNum());
			total2NumList.add(preMonthHolidayOpCureNumberRecord.getOtherMonthNum()==null?0:preMonthHolidayOpCureNumberRecord.getOtherMonthNum().intValue());
			list3.add(preMonthHolidayCureNumberRecord.getOtherMonthNum());
			total2NumList.add(preMonthHolidayCureNumberRecord.getOtherMonthNum()==null?0:preMonthHolidayCureNumberRecord.getOtherMonthNum().intValue());
			list3.add(preMonthholidayDiagHandleNumberRecord.getOtherMonthNum());
			total2NumList.add(preMonthholidayDiagHandleNumberRecord.getOtherMonthNum()==null?0:preMonthholidayDiagHandleNumberRecord.getOtherMonthNum().intValue());
			echartsBaseRecord3.setData3List(list3);
			
			int total2Num = Collections.max(total2NumList);
			if(total2Num>0) {
				echartsBaseRecord3.setTotalNum(NumUtil.getAvgNum(total2Num));
				echartsBaseRecord3.setAvgNum(NumUtil.getAvgNum(total2Num)/10);
			}else {
				echartsBaseRecord3.setTotalNum(1000);
				echartsBaseRecord3.setAvgNum(100);
			}

			opNumberInfo.setEchartsBaseRecord3(echartsBaseRecord3);

		} catch (Exception e) {
			e.printStackTrace();
		}

		return opNumberInfo;
	}

	public OperationNumber getOperationNumber(String dateStr, String orgCode) throws ParseException {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
		Date date = df.parse(dateStr);
		Map<String, Object> firstLastDayStrMap = DateUtil.getFirstLastDayByMonth(date, "yyyy-MM-dd", true);
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setOrgCode(orgCode);
		mrInBasicQuery.setStartDateStr(MapUtils.getString(firstLastDayStrMap, "first"));
		mrInBasicQuery.setEndDateStr(MapUtils.getString(firstLastDayStrMap, "last"));
		OperationNumber operationNumber = mrInBasicMapper.getOperationDataInfo(mrInBasicQuery);
		BigDecimal outNum = mrInBasicMapper.getMrInBasicCount(mrInBasicQuery);
		operationNumber.setOutNum(outNum);
		BigDecimal operationNum = mrInBasicMapper.getOperationCount(mrInBasicQuery);
		operationNumber.setOperationNum(operationNum);
		return operationNumber;
	}

	public OperationNumber getOperationNumber(String startTimeStr, String endTimeStr, String orgCode)
			throws ParseException {
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setOrgCode(orgCode);
		mrInBasicQuery.setStartDateStr(startTimeStr + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTimeStr + " 23:59:59");
		OperationNumber operationNumber = mrInBasicMapper.getOperationDataInfo(mrInBasicQuery);
		BigDecimal outNum = mrInBasicMapper.getMrInBasicCount(mrInBasicQuery);
		operationNumber.setOutNum(outNum);
		BigDecimal operationNum = mrInBasicMapper.getOperationCount(mrInBasicQuery);
		operationNumber.setOperationNum(operationNum);
		return operationNumber;
	}

	/**
	 * 如果是总费用除以10000
	 * 
	 * @param b1
	 * @param b2
	 * @param isTotalFee
	 * @return
	 */
	public BaseDataRecord geBaseDataRecord(BigDecimal b1, BigDecimal b2, String feeType) {
		BaseDataRecord costRecord = new BaseDataRecord();
		if ("totalFee".equals(feeType)) {
			costRecord.setMonthNum(b1.divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP));
			costRecord.setOtherMonthNum(b2.divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP));
			costRecord.setOpNum(
					BigDecimalUtil.getNumDifference(b1, b2).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP));
		} else if ("yzbFee".equals(feeType)) {
			BigDecimal monthNum = b1.multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
			BigDecimal otherMonthNum = b2.multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
			costRecord.setMonthNum(monthNum);
			costRecord.setOtherMonthNum(otherMonthNum);
			costRecord.setOpNum(BigDecimalUtil.getNumDifference(monthNum, otherMonthNum));
			costRecord.setOp(BigDecimalUtil.getCompareResult(monthNum, otherMonthNum));
			costRecord.setRange(BigDecimalUtil.getCompareRateResult(monthNum, otherMonthNum));
			costRecord.setRangePercent(BigDecimalUtil.getCompareRate(monthNum, otherMonthNum));
			return costRecord;

		} else if ("people".equals(feeType)) {
			costRecord.setMonthNum(b1);
			costRecord.setOtherMonthNum(b2);
			costRecord.setOpNum(BigDecimalUtil.getNumDifference(b1, b2, true));
		} else {
			costRecord.setMonthNum(b1);
			costRecord.setOtherMonthNum(b2);
			costRecord.setOpNum(BigDecimalUtil.getNumDifference(b1, b2));
		}

		costRecord.setOp(BigDecimalUtil.getCompareResult(b1, b2));
		costRecord.setRange(BigDecimalUtil.getCompareRateResult(b1, b2));
		costRecord.setRangePercent(BigDecimalUtil.getCompareRate(b1, b2));
		return costRecord;

	}

	public CostFee getCostFee(String dateStr, String orgCode) throws ParseException {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
		Date date = df.parse(dateStr);
		Map<String, Object> firstLastDayStrMap = DateUtil.getFirstLastDayByMonth(date, "yyyy-MM-dd", true);
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setOrgCode(orgCode);
		mrInBasicQuery.setStartDateStr(MapUtils.getString(firstLastDayStrMap, "first"));
		mrInBasicQuery.setEndDateStr(MapUtils.getString(firstLastDayStrMap, "last"));
		return mrInBasicMapper.getCostFeeInfo(mrInBasicQuery);
	}

	public CostFee getCostFee(String startTimeStr, String endTimeStr, String orgCode) throws ParseException {
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setOrgCode(orgCode);
		mrInBasicQuery.setStartDateStr(startTimeStr + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTimeStr + " 23:59:59");
		return mrInBasicMapper.getCostFeeInfo(mrInBasicQuery);
	}

	/**
	 * 获取上月日期
	 * 
	 * @param params
	 * @return
	 */
	public static String getPreMonthDatestr(String params) {
		String mon = null;
		String yearStr = params.split("-")[0];
		String monthStr = params.split("-")[1];
		Integer month = Integer.valueOf(monthStr);
		Integer year = Integer.valueOf(yearStr);
		if (month == 1) {
			mon = (year - 1) + "-" + 12;
		} else {
			mon = year + "-" + (month < 11 ? "0" + (month - 1) : (month - 1));
		}

		return mon;
	}

	// 获取上一年的月信息
	public static String getPreYearMonthDatestr(String params) {
		String yearStr = params.split("-")[0];
		String monthStr = params.split("-")[1];
		Integer year = Integer.valueOf(yearStr);

		return (year - 1) + "-" + monthStr;
	}

	@Transactional(readOnly = true)
	@Override
	public OutHospStatisIndexInfo getOutHospStatisIndexInfo(StatisticalReportParam statisticalReportParam,
			String orgCode) {

		OutHospStatisIndexInfo outHospStatisIndexInfo = new OutHospStatisIndexInfo();
		try {

			String startTime = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
			String endTime = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
			MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
			mrInBasicQuery.setOrgCode(orgCode);
			mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
			mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
			List<OutHospStatisIndexRecord> outHospStatisIndexRecordList = mrInBasicMapper
					.getOutHospNumAndDeathNumByDept(mrInBasicQuery);

			// 三四级、手术治疗性操作性人次数
			List<Map<String, Object>> opCureMapList = mrInBasicMapper.getOpCureByDept(mrInBasicQuery);

			Map<String, Map<String, Object>> opCureKsMap = new HashMap<>();

			for (Map<String, Object> opCureMap : opCureMapList) {
				String officeCode = MapUtils.getString(opCureMap, "OFFICECODE");
				opCureKsMap.put(officeCode, opCureMap);
			}

			// 住院平均费用、药占比、一次性耗材占比
			List<OutHospStatisIndexRecord> costFeeOutHospStatisIndexRecordList = mrInBasicMapper
					.getCostFeeByDept(mrInBasicQuery);

			Map<String, OutHospStatisIndexRecord> feeKsMap = new HashMap<>();

			for (OutHospStatisIndexRecord costFeeOutHospStatisIndexRecord : costFeeOutHospStatisIndexRecordList) {
				String officeCode = costFeeOutHospStatisIndexRecord.getOfficeCode();
				feeKsMap.put(officeCode, costFeeOutHospStatisIndexRecord);
			}

			// 计算出院当天再住院人数
			List<RepeatInHosp> repeatInHospList = mrInBasicMapper.getRepeatInHospNum(mrInBasicQuery);
			Map<String, Integer> repeatDeptKsMap = countRepeatInHospNumByDept(repeatInHospList);
			
			List<OutHospStatisIndexRecord> newOutHospStatisIndexRecordList = new ArrayList<>();

			for (OutHospStatisIndexRecord outHospStatisIndexRecord : outHospStatisIndexRecordList) {
				String officeCode = outHospStatisIndexRecord.getOfficeCode();
				mrInBasicQuery.setOfficeCode(officeCode);
				@SuppressWarnings("unchecked")
				Map<String, Object> opCureMap = MapUtils.getMap(opCureKsMap, officeCode);
				// 手术治疗性操作性人次数
				Integer surgicalTherapeuticOpNum = MapUtils.getInteger(opCureMap, "THERAPEOPNUM");
				outHospStatisIndexRecord.setSurgicalTherapeuticOpNum(surgicalTherapeuticOpNum);
				// 三四级、手术治疗性操作性人次数
				Integer thirdForthSurgicalTherapeuticOpNum = MapUtils.getInteger(opCureMap, "THIRDFOURTHLEVELOPNUM");
				outHospStatisIndexRecord.setThirdForthSurgicalTherapeuticOpNum(thirdForthSurgicalTherapeuticOpNum);
				OutHospStatisIndexRecord costFeeOutHospStatisIndexRecord = feeKsMap.get(officeCode);
				
				if(costFeeOutHospStatisIndexRecord==null) {
				
					continue;
				}
				
				// 平均住院费用
				if(costFeeOutHospStatisIndexRecord.getAvgCostFee()==null) {
					outHospStatisIndexRecord
					.setAvgCostFee(new BigDecimal(0));
				}else {
					outHospStatisIndexRecord
					.setAvgCostFee(BigDecimalUtil.getScale(costFeeOutHospStatisIndexRecord.getAvgCostFee(), 0));
				}
				
				// 药占比
				outHospStatisIndexRecord.setDrugProportion(costFeeOutHospStatisIndexRecord.getDrugProportion());
				// 一次性耗材占比
				outHospStatisIndexRecord.setDisposableConsumableProportion(
						costFeeOutHospStatisIndexRecord.getDisposableConsumableProportion());
				outHospStatisIndexRecord.setReOutHospInNum(
						repeatDeptKsMap.get(officeCode) == null ? 0 : MapUtils.getInteger(repeatDeptKsMap, officeCode));
				// 出院当天再住院数量
				outHospStatisIndexRecord.setReOutHospInNum(MapUtils.getInteger(repeatDeptKsMap, officeCode) == null ? 0
						: MapUtils.getInteger(repeatDeptKsMap, officeCode));
				// 术前术后平均住院天数
				OutHospStatisIndexRecord beforeAfterOpOutHospStatisIndexRecord = mrInBasicMapper
						.getBeforeAfterOpInHospitalDays(mrInBasicQuery);
				outHospStatisIndexRecord
						.setBeforeOpAvgInHospDays(beforeAfterOpOutHospStatisIndexRecord.getBeforeOpAvgInHospDays());
				outHospStatisIndexRecord
						.setAfterOpAvgInHospDays(beforeAfterOpOutHospStatisIndexRecord.getAfterOpAvgInHospDays());

				// 三四级治疗性操作性占比
				if (surgicalTherapeuticOpNum != null && thirdForthSurgicalTherapeuticOpNum != null) {
					outHospStatisIndexRecord
							.setThirdForthSurgicalTherapeuticOpNumRate(surgicalTherapeuticOpNum > 0
									? BigDecimalUtil.getDivideRate(new BigDecimal(thirdForthSurgicalTherapeuticOpNum),
											new BigDecimal(surgicalTherapeuticOpNum))
									: new BigDecimal(0));
				}
				
				
				newOutHospStatisIndexRecordList.add(outHospStatisIndexRecord);

			}

			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {

					return o2.getOutNum() - o1.getOutNum();
				}
			});
			// 出院人数前6科室
			OutHospStatisIndexItem outNumRecord = new OutHospStatisIndexItem();
			for (int i = 0; i < newOutHospStatisIndexRecordList.size(); i++) {
				if (i > 5)
					continue;
				OutHospStatisIndexRecord outRecord = newOutHospStatisIndexRecordList.get(i);

				if (i == 0) {
					outNumRecord.setItemName1(outRecord.getOfficeName());
					outNumRecord.setItemValue1(new BigDecimal(outRecord.getOutNum().toString()));
				} else if (i == 1) {
					outNumRecord.setItemName2(outRecord.getOfficeName());
					outNumRecord.setItemValue2(new BigDecimal(outRecord.getOutNum().toString()));
				} else if (i == 2) {
					outNumRecord.setItemName3(outRecord.getOfficeName());
					outNumRecord.setItemValue3(new BigDecimal(outRecord.getOutNum().toString()));
				} else if (i == 3) {
					outNumRecord.setItemName4(outRecord.getOfficeName());
					outNumRecord.setItemValue4(new BigDecimal(outRecord.getOutNum().toString()));
				} else if (i == 4) {
					outNumRecord.setItemName5(outRecord.getOfficeName());
					outNumRecord.setItemValue5(new BigDecimal(outRecord.getOutNum().toString()));
				} else if (i == 5) {
					outNumRecord.setItemName6(outRecord.getOfficeName());
					outNumRecord.setItemValue6(new BigDecimal(outRecord.getOutNum().toString()));
				}

			}

			outHospStatisIndexInfo.setOutNumRecord(outNumRecord);

			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getDeathNum() - o1.getDeathNum();
				}
			});
			// 死亡人数前6科室
			OutHospStatisIndexItem deathNumRecord = new OutHospStatisIndexItem();
			for (int i = 0; i < newOutHospStatisIndexRecordList.size(); i++) {
				if (i > 10)
					continue;
				OutHospStatisIndexRecord deathRecord = newOutHospStatisIndexRecordList.get(i);
				OutHospStatisIndexRecord preDeathRecord = null;
				if (i == 0) {
					deathNumRecord.setItemName1(deathRecord.getOfficeName());
					deathNumRecord.setItemValue1(new BigDecimal(deathRecord.getDeathNum().toString()));
				} else if (i == 1) {
					deathNumRecord.setItemName2(deathRecord.getOfficeName());
					deathNumRecord.setItemValue2(new BigDecimal(deathRecord.getDeathNum().toString()));
				} else if (i == 2) {
					deathNumRecord.setItemName3(deathRecord.getOfficeName());
					deathNumRecord.setItemValue3(new BigDecimal(deathRecord.getDeathNum().toString()));
				} else if (i == 3) {
					deathNumRecord.setItemName4(deathRecord.getOfficeName());
					deathNumRecord.setItemValue4(new BigDecimal(deathRecord.getDeathNum().toString()));
				} else if (i == 4) {
					deathNumRecord.setItemName5(deathRecord.getOfficeName());
					deathNumRecord.setItemValue5(new BigDecimal(deathRecord.getDeathNum().toString()));
				} else if (i == 5) {
					deathNumRecord.setItemName6(deathRecord.getOfficeName());
					deathNumRecord.setItemValue6(new BigDecimal(deathRecord.getDeathNum().toString()));
				} else if (i == 6) {
					preDeathRecord = newOutHospStatisIndexRecordList.get(i - 1);
					if (preDeathRecord.getDeathNum() == deathRecord.getDeathNum()) {
						deathNumRecord.setItemName7(deathRecord.getOfficeName());
						deathNumRecord.setItemValue7(new BigDecimal(deathRecord.getDeathNum().toString()));
					}
				} else if (i == 7) {
					preDeathRecord = newOutHospStatisIndexRecordList.get(i - 1);
					if (preDeathRecord.getDeathNum() == deathRecord.getDeathNum()) {
						deathNumRecord.setItemName8(deathRecord.getOfficeName());
						deathNumRecord.setItemValue8(new BigDecimal(deathRecord.getDeathNum().toString()));
					}
				} else if (i == 8) {
					preDeathRecord = newOutHospStatisIndexRecordList.get(i - 1);
					if (preDeathRecord.getDeathNum() == deathRecord.getDeathNum()) {
						deathNumRecord.setItemName9(deathRecord.getOfficeName());
						deathNumRecord.setItemValue9(new BigDecimal(deathRecord.getDeathNum().toString()));
					}
				}

			}
			outHospStatisIndexInfo.setDeathNumRecord(deathNumRecord);

			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getAvgInHospDays().compareTo(o1.getAvgInHospDays());
				}
			});
			// 平均住院天数前5科室
			OutHospStatisIndexItem avgmoreInHospDaysRecord = new OutHospStatisIndexItem();
			int avgInHospDaysMoreIndex = 0;
			for (OutHospStatisIndexRecord record : newOutHospStatisIndexRecordList) {
				if (avgInHospDaysMoreIndex > 4)
					continue;
				// OutHospStatisIndexRecord record = outHospStatisIndexRecordList.get(i);
				// 人数不超过20不计入其中
				if (record.getOutNum() <= 20) {
					continue;
				}
				if (avgInHospDaysMoreIndex == 0) {
					avgmoreInHospDaysRecord.setItemName1(record.getOfficeName());
					avgmoreInHospDaysRecord.setItemValue1(record.getAvgInHospDays());
				} else if (avgInHospDaysMoreIndex == 1) {
					avgmoreInHospDaysRecord.setItemName2(record.getOfficeName());
					avgmoreInHospDaysRecord.setItemValue2(record.getAvgInHospDays());
				} else if (avgInHospDaysMoreIndex == 2) {
					avgmoreInHospDaysRecord.setItemName3(record.getOfficeName());
					avgmoreInHospDaysRecord.setItemValue3(record.getAvgInHospDays());
				} else if (avgInHospDaysMoreIndex == 3) {
					avgmoreInHospDaysRecord.setItemName4(record.getOfficeName());
					avgmoreInHospDaysRecord.setItemValue4(record.getAvgInHospDays());
				} else if (avgInHospDaysMoreIndex == 4) {
					avgmoreInHospDaysRecord.setItemName5(record.getOfficeName());
					avgmoreInHospDaysRecord.setItemValue5(record.getAvgInHospDays());
				}
				avgInHospDaysMoreIndex++;

			}
			outHospStatisIndexInfo.setAvgInDaysMoreRecord(avgmoreInHospDaysRecord);

			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o1.getAvgInHospDays().compareTo(o2.getAvgInHospDays());
				}
			});
			// 平均住院天数较少前5科室
			OutHospStatisIndexItem avgLessInHospDaysRecord = new OutHospStatisIndexItem();
			int avgInHospDaysLessIndex = 0;
			for (OutHospStatisIndexRecord record : newOutHospStatisIndexRecordList) {
				if (avgInHospDaysLessIndex > 4)
					continue;
				// 人数不超过20不计入其中
				if (record.getOutNum() <= 20) {
					continue;
				}

				if (avgInHospDaysLessIndex == 0) {
					avgLessInHospDaysRecord.setItemName1(record.getOfficeName());
					avgLessInHospDaysRecord.setItemValue1(record.getAvgInHospDays());
				} else if (avgInHospDaysLessIndex == 1) {
					avgLessInHospDaysRecord.setItemName2(record.getOfficeName());
					avgLessInHospDaysRecord.setItemValue2(record.getAvgInHospDays());
				} else if (avgInHospDaysLessIndex == 2) {
					avgLessInHospDaysRecord.setItemName3(record.getOfficeName());
					avgLessInHospDaysRecord.setItemValue3(record.getAvgInHospDays());
				} else if (avgInHospDaysLessIndex == 3) {
					avgLessInHospDaysRecord.setItemName4(record.getOfficeName());
					avgLessInHospDaysRecord.setItemValue4(record.getAvgInHospDays());
				} else if (avgInHospDaysLessIndex == 4) {
					avgLessInHospDaysRecord.setItemName5(record.getOfficeName());
					avgLessInHospDaysRecord.setItemValue5(record.getAvgInHospDays());
				}
				avgInHospDaysLessIndex++;

			}
			outHospStatisIndexInfo.setAvgInDaysLessRecord(avgLessInHospDaysRecord);

			// 术前平均住院天数较少5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o1.getBeforeOpAvgInHospDays().compareTo(o2.getBeforeOpAvgInHospDays());
				}
			});
			OutHospStatisIndexItem opBeforeInHospDaysLessRecord = new OutHospStatisIndexItem();
			int opBeforeInHospDaysLessIndex = 0;
			for (OutHospStatisIndexRecord record : newOutHospStatisIndexRecordList) {
				if (opBeforeInHospDaysLessIndex > 4)
					continue;
				// = outHospStatisIndexRecordList.get(i);
				// 手术及治疗性操作人次数<20的科室不参与
				if (record.getSurgicalTherapeuticOpNum() < 20)
					continue;
				// （注：保健神经病房、保健内分泌病房、东院保健神经内科病房、东院保健呼吸病房、小儿神经科病房、内分泌科病房、皮肤科病房因手术量太少，该指标不适宜）
				if (Constant.PRE_OP_EXCLUDE_LESS_DEPTCODES.contains(record.getOfficeCode()))
					continue;

				if (opBeforeInHospDaysLessIndex == 0) {
					opBeforeInHospDaysLessRecord.setItemName1(record.getOfficeName());
					opBeforeInHospDaysLessRecord.setItemValue1(record.getBeforeOpAvgInHospDays());
				} else if (opBeforeInHospDaysLessIndex == 1) {
					opBeforeInHospDaysLessRecord.setItemName2(record.getOfficeName());
					opBeforeInHospDaysLessRecord.setItemValue2(record.getBeforeOpAvgInHospDays());
				} else if (opBeforeInHospDaysLessIndex == 2) {
					opBeforeInHospDaysLessRecord.setItemName3(record.getOfficeName());
					opBeforeInHospDaysLessRecord.setItemValue3(record.getBeforeOpAvgInHospDays());
				} else if (opBeforeInHospDaysLessIndex == 3) {
					opBeforeInHospDaysLessRecord.setItemName4(record.getOfficeName());
					opBeforeInHospDaysLessRecord.setItemValue4(record.getBeforeOpAvgInHospDays());
				} else if (opBeforeInHospDaysLessIndex == 4) {
					opBeforeInHospDaysLessRecord.setItemName5(record.getOfficeName());
					opBeforeInHospDaysLessRecord.setItemValue5(record.getBeforeOpAvgInHospDays());
				}
				opBeforeInHospDaysLessIndex++;

			}
			outHospStatisIndexInfo.setBeforeOpAvgInDaysLessRecord(opBeforeInHospDaysLessRecord);

			// 术前平均住院天数前5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getBeforeOpAvgInHospDays().compareTo(o1.getBeforeOpAvgInHospDays());
				}
			});
			OutHospStatisIndexItem opBeforeInHospDaysRecord = new OutHospStatisIndexItem();
			int opBeforeInHospDaysMoreIndex = 0;
			for (OutHospStatisIndexRecord record : newOutHospStatisIndexRecordList) {
				if (opBeforeInHospDaysMoreIndex > 4)
					continue;
				// = outHospStatisIndexRecordList.get(i);
				// 手术及治疗性操作人次数<20的科室不参与
				if (record.getSurgicalTherapeuticOpNum() < 20)
					continue;
				// 因睡眠医学中心、东院血液科病房、东院心外监护室、保健外科病房、小儿肾病风湿免疫科病房手术量太小，该指标不适宜
				if (Constant.PRE_OP_EXCLUDE_MORE_DEPTCODES.contains(record.getOfficeCode()))
					continue;

				if (opBeforeInHospDaysMoreIndex == 0) {
					opBeforeInHospDaysRecord.setItemName1(record.getOfficeName());
					opBeforeInHospDaysRecord.setItemValue1(record.getBeforeOpAvgInHospDays());
				} else if (opBeforeInHospDaysMoreIndex == 1) {
					opBeforeInHospDaysRecord.setItemName2(record.getOfficeName());
					opBeforeInHospDaysRecord.setItemValue2(record.getBeforeOpAvgInHospDays());
				} else if (opBeforeInHospDaysMoreIndex == 2) {
					opBeforeInHospDaysRecord.setItemName3(record.getOfficeName());
					opBeforeInHospDaysRecord.setItemValue3(record.getBeforeOpAvgInHospDays());
				} else if (opBeforeInHospDaysMoreIndex == 3) {
					opBeforeInHospDaysRecord.setItemName4(record.getOfficeName());
					opBeforeInHospDaysRecord.setItemValue4(record.getBeforeOpAvgInHospDays());
				} else if (opBeforeInHospDaysMoreIndex == 4) {
					opBeforeInHospDaysRecord.setItemName5(record.getOfficeName());
					opBeforeInHospDaysRecord.setItemValue5(record.getBeforeOpAvgInHospDays());
				}
				opBeforeInHospDaysMoreIndex++;

			}
			outHospStatisIndexInfo.setBeforeOpAvgInDaysMoreRecord(opBeforeInHospDaysRecord);

			// 术后平均住院天数较少5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o1.getAfterOpAvgInHospDays().compareTo(o2.getAfterOpAvgInHospDays());
				}
			});
			OutHospStatisIndexItem opAfterInHospDaysLessRecord = new OutHospStatisIndexItem();
			int opAfterInHospDaysLessIndex = 0;
			for (OutHospStatisIndexRecord record : newOutHospStatisIndexRecordList) {
				if (opAfterInHospDaysLessIndex > 4)
					continue;
				// 手术及治疗性操作人次数<20的科室不参与
				if (record.getSurgicalTherapeuticOpNum() < 20)
					continue;
				// 东院保健神经科病房、保健神经科病房、内分泌科病房、东院心外监护室因手术量太少，该指标不适用
				if (Constant.AFTER_OP_EXCLUDE_LESS_DEPTCODES.contains(record.getOfficeCode()))
					continue;

				// OutHospStatisIndexRecord record = outHospStatisIndexRecordList.get(i);

				if (opAfterInHospDaysLessIndex == 0) {
					opAfterInHospDaysLessRecord.setItemName1(record.getOfficeName());
					opAfterInHospDaysLessRecord.setItemValue1(record.getAfterOpAvgInHospDays());
				} else if (opAfterInHospDaysLessIndex == 1) {
					opAfterInHospDaysLessRecord.setItemName2(record.getOfficeName());
					opAfterInHospDaysLessRecord.setItemValue2(record.getAfterOpAvgInHospDays());
				} else if (opAfterInHospDaysLessIndex == 2) {
					opAfterInHospDaysLessRecord.setItemName3(record.getOfficeName());
					opAfterInHospDaysLessRecord.setItemValue3(record.getAfterOpAvgInHospDays());
				} else if (opAfterInHospDaysLessIndex == 3) {
					opAfterInHospDaysLessRecord.setItemName4(record.getOfficeName());
					opAfterInHospDaysLessRecord.setItemValue4(record.getAfterOpAvgInHospDays());
				} else if (opAfterInHospDaysLessIndex == 4) {
					opAfterInHospDaysLessRecord.setItemName5(record.getOfficeName());
					opAfterInHospDaysLessRecord.setItemValue5(record.getAfterOpAvgInHospDays());
				}
				opAfterInHospDaysLessIndex++;

			}
			outHospStatisIndexInfo.setAfterOpAvgInDaysLessRecord(opAfterInHospDaysLessRecord);

			// 术后平均住院天数较多5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getAfterOpAvgInHospDays().compareTo(o1.getAfterOpAvgInHospDays());
				}
			});
			OutHospStatisIndexItem opAfterInHospDaysRecord = new OutHospStatisIndexItem();
			int opAfterInHospDaysIndex = 0;
			for (OutHospStatisIndexRecord record : newOutHospStatisIndexRecordList) {
				if (opAfterInHospDaysIndex > 4)
					continue;

				// 手术及治疗性操作人次数<20的科室不参与
				if (record.getSurgicalTherapeuticOpNum() < 20)
					continue;
				// 因小儿神经科病房、风湿免疫科、小儿呼吸综合科病房、小儿肾病风湿免疫科病房、东院保健呼吸科、外科ICU病房、血液科、保健内分泌科病房、全科医学科病房、保健呼吸科病房、东院血液科病房、神经内科病房、东院急诊ICU、保健外科病房虽然术后平均住院天是较高手术量太小，该指标不具代表性
				if (Constant.AFTER_OP_EXCLUDE_MORE_DEPTCODES.contains(record.getOfficeCode()))
					continue;
				// OutHospStatisIndexRecord record = outHospStatisIndexRecordList.get(i);

				if (opAfterInHospDaysIndex == 0) {
					opAfterInHospDaysRecord.setItemName1(record.getOfficeName());
					opAfterInHospDaysRecord.setItemValue1(record.getAfterOpAvgInHospDays());
				} else if (opAfterInHospDaysIndex == 1) {
					opAfterInHospDaysRecord.setItemName2(record.getOfficeName());
					opAfterInHospDaysRecord.setItemValue2(record.getAfterOpAvgInHospDays());
				} else if (opAfterInHospDaysIndex == 2) {
					opAfterInHospDaysRecord.setItemName3(record.getOfficeName());
					opAfterInHospDaysRecord.setItemValue3(record.getAfterOpAvgInHospDays());
				} else if (opAfterInHospDaysIndex == 3) {
					opAfterInHospDaysRecord.setItemName4(record.getOfficeName());
					opAfterInHospDaysRecord.setItemValue4(record.getAfterOpAvgInHospDays());
				} else if (opAfterInHospDaysIndex == 4) {
					opAfterInHospDaysRecord.setItemName5(record.getOfficeName());
					opAfterInHospDaysRecord.setItemValue5(record.getAfterOpAvgInHospDays());
				}
				opAfterInHospDaysIndex++;

			}
			outHospStatisIndexInfo.setAfterOpAvgInDaysMoreRecord(opAfterInHospDaysRecord);

			// 手术及治疗性操作人次数较多5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getSurgicalTherapeuticOpNum().compareTo(o1.getSurgicalTherapeuticOpNum());
				}
			});
			int surgicalTherapeuticOpNumMoreIndex = 0;
			OutHospStatisIndexItem surgicalTherapeuticOpNumRecord = new OutHospStatisIndexItem();
			for (OutHospStatisIndexRecord record : newOutHospStatisIndexRecordList) {
				if (surgicalTherapeuticOpNumMoreIndex > 4)
					continue;
				if (surgicalTherapeuticOpNumMoreIndex == 0) {
					surgicalTherapeuticOpNumRecord.setItemName1(record.getOfficeName());
					surgicalTherapeuticOpNumRecord
							.setItemValue1(new BigDecimal(record.getSurgicalTherapeuticOpNum().toString()));
				} else if (surgicalTherapeuticOpNumMoreIndex == 1) {
					surgicalTherapeuticOpNumRecord.setItemName2(record.getOfficeName());
					surgicalTherapeuticOpNumRecord
							.setItemValue2(new BigDecimal(record.getSurgicalTherapeuticOpNum().toString()));
				} else if (surgicalTherapeuticOpNumMoreIndex == 2) {
					surgicalTherapeuticOpNumRecord.setItemName3(record.getOfficeName());
					surgicalTherapeuticOpNumRecord
							.setItemValue3(new BigDecimal(record.getSurgicalTherapeuticOpNum().toString()));
				} else if (surgicalTherapeuticOpNumMoreIndex == 3) {
					surgicalTherapeuticOpNumRecord.setItemName4(record.getOfficeName());
					surgicalTherapeuticOpNumRecord
							.setItemValue4(new BigDecimal(record.getSurgicalTherapeuticOpNum().toString()));
				} else if (surgicalTherapeuticOpNumMoreIndex == 4) {
					surgicalTherapeuticOpNumRecord.setItemName5(record.getOfficeName());
					surgicalTherapeuticOpNumRecord
							.setItemValue5(new BigDecimal(record.getSurgicalTherapeuticOpNum().toString()));
				}

				surgicalTherapeuticOpNumMoreIndex++;

			}
			outHospStatisIndexInfo.setSurgicalTherapeuticMoreOpNumRecord(surgicalTherapeuticOpNumRecord);

			// 三四级手术及治疗性操作人次数较多5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getThirdForthSurgicalTherapeuticOpNum()
							.compareTo(o1.getThirdForthSurgicalTherapeuticOpNum());
				}
			});
			OutHospStatisIndexItem thirdForthSurgicalTherapeuticOpNumRecord = new OutHospStatisIndexItem();
			int thirdForthSurgicalTherapeuticIndex = 0;
			for (OutHospStatisIndexRecord record : newOutHospStatisIndexRecordList) {
				if (thirdForthSurgicalTherapeuticIndex > 4)
					continue;
				// OutHospStatisIndexRecord record = outHospStatisIndexRecordList.get(i);

				if (thirdForthSurgicalTherapeuticIndex == 0) {
					thirdForthSurgicalTherapeuticOpNumRecord.setItemName1(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRecord
							.setItemValue1(new BigDecimal(record.getThirdForthSurgicalTherapeuticOpNum().toString()));
				} else if (thirdForthSurgicalTherapeuticIndex == 1) {
					thirdForthSurgicalTherapeuticOpNumRecord.setItemName2(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRecord
							.setItemValue2(new BigDecimal(record.getThirdForthSurgicalTherapeuticOpNum().toString()));
				} else if (thirdForthSurgicalTherapeuticIndex == 2) {
					thirdForthSurgicalTherapeuticOpNumRecord.setItemName3(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRecord
							.setItemValue3(new BigDecimal(record.getThirdForthSurgicalTherapeuticOpNum().toString()));
				} else if (thirdForthSurgicalTherapeuticIndex == 3) {
					thirdForthSurgicalTherapeuticOpNumRecord.setItemName4(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRecord
							.setItemValue4(new BigDecimal(record.getThirdForthSurgicalTherapeuticOpNum().toString()));
				} else if (thirdForthSurgicalTherapeuticIndex == 4) {
					thirdForthSurgicalTherapeuticOpNumRecord.setItemName5(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRecord
							.setItemValue5(new BigDecimal(record.getThirdForthSurgicalTherapeuticOpNum().toString()));
				}

				thirdForthSurgicalTherapeuticIndex++;

			}
			outHospStatisIndexInfo
					.setThirdForthSurgicalTherapeuticMoreOpNumRecord(thirdForthSurgicalTherapeuticOpNumRecord);

			// 平均费用数较少5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o1.getAvgCostFee().compareTo(o2.getAvgCostFee());
				}
			});
			OutHospStatisIndexItem avgCostFeeLessRecord = new OutHospStatisIndexItem();
			for (int i = 0; i < newOutHospStatisIndexRecordList.size(); i++) {
				if (i > 4)
					continue;
				OutHospStatisIndexRecord record = newOutHospStatisIndexRecordList.get(i);

				if (i == 0) {
					avgCostFeeLessRecord.setItemName1(record.getOfficeName());
					avgCostFeeLessRecord.setItemValue1(record.getAvgCostFee());
				} else if (i == 1) {
					avgCostFeeLessRecord.setItemName2(record.getOfficeName());
					avgCostFeeLessRecord.setItemValue2(record.getAvgCostFee());
				} else if (i == 2) {
					avgCostFeeLessRecord.setItemName3(record.getOfficeName());
					avgCostFeeLessRecord.setItemValue3(record.getAvgCostFee());
				} else if (i == 3) {
					avgCostFeeLessRecord.setItemName4(record.getOfficeName());
					avgCostFeeLessRecord.setItemValue4(record.getAvgCostFee());
				} else if (i == 4) {
					avgCostFeeLessRecord.setItemName5(record.getOfficeName());
					avgCostFeeLessRecord.setItemValue5(record.getAvgCostFee());
				}

			}
			outHospStatisIndexInfo.setAvgCostFeeLessRecord(avgCostFeeLessRecord);

			// 平均费用数较多5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getAvgCostFee().compareTo(o1.getAvgCostFee());
				}
			});
			OutHospStatisIndexItem avgCostFeeMoreRecord = new OutHospStatisIndexItem();
			for (int i = 0; i < newOutHospStatisIndexRecordList.size(); i++) {
				if (i > 4)
					continue;
				OutHospStatisIndexRecord record = newOutHospStatisIndexRecordList.get(i);

				if (i == 0) {
					avgCostFeeMoreRecord.setItemName1(record.getOfficeName());
					avgCostFeeMoreRecord.setItemValue1(record.getAvgCostFee());
				} else if (i == 1) {
					avgCostFeeMoreRecord.setItemName2(record.getOfficeName());
					avgCostFeeMoreRecord.setItemValue2(record.getAvgCostFee());
				} else if (i == 2) {
					avgCostFeeMoreRecord.setItemName3(record.getOfficeName());
					avgCostFeeMoreRecord.setItemValue3(record.getAvgCostFee());
				} else if (i == 3) {
					avgCostFeeMoreRecord.setItemName4(record.getOfficeName());
					avgCostFeeMoreRecord.setItemValue4(record.getAvgCostFee());
				} else if (i == 4) {
					avgCostFeeMoreRecord.setItemName5(record.getOfficeName());
					avgCostFeeMoreRecord.setItemValue5(record.getAvgCostFee());
				}

			}
			outHospStatisIndexInfo.setAvgCostFeeMoreRecord(avgCostFeeMoreRecord);

			// 药占比较少5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o1.getDrugProportion().compareTo(o2.getDrugProportion());
				}
			});
			OutHospStatisIndexItem drugProportionLessRecord = new OutHospStatisIndexItem();
			for (int i = 0; i < newOutHospStatisIndexRecordList.size(); i++) {
				if (i > 4)
					continue;
				OutHospStatisIndexRecord record = newOutHospStatisIndexRecordList.get(i);

				if (i == 0) {
					drugProportionLessRecord.setItemName1(record.getOfficeName());
					drugProportionLessRecord.setItemValue1(record.getDrugProportion());
				} else if (i == 1) {
					drugProportionLessRecord.setItemName2(record.getOfficeName());
					drugProportionLessRecord.setItemValue2(record.getDrugProportion());
				} else if (i == 2) {
					drugProportionLessRecord.setItemName3(record.getOfficeName());
					drugProportionLessRecord.setItemValue3(record.getDrugProportion());
				} else if (i == 3) {
					drugProportionLessRecord.setItemName4(record.getOfficeName());
					drugProportionLessRecord.setItemValue4(record.getDrugProportion());
				} else if (i == 4) {
					drugProportionLessRecord.setItemName5(record.getOfficeName());
					drugProportionLessRecord.setItemValue5(record.getDrugProportion());
				}

			}
			outHospStatisIndexInfo.setDrugProportionLessRecord(drugProportionLessRecord);

			// 药占比较多5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getDrugProportion().compareTo(o1.getDrugProportion());
				}
			});
			OutHospStatisIndexItem drugProportionMoreRecord = new OutHospStatisIndexItem();
			for (int i = 0; i < newOutHospStatisIndexRecordList.size(); i++) {
				if (i > 4)
					continue;
				OutHospStatisIndexRecord record = newOutHospStatisIndexRecordList.get(i);

				if (i == 0) {
					drugProportionMoreRecord.setItemName1(record.getOfficeName());
					drugProportionMoreRecord.setItemValue1(record.getDrugProportion());
				} else if (i == 1) {
					drugProportionMoreRecord.setItemName2(record.getOfficeName());
					drugProportionMoreRecord.setItemValue2(record.getDrugProportion());
				} else if (i == 2) {
					drugProportionMoreRecord.setItemName3(record.getOfficeName());
					drugProportionMoreRecord.setItemValue3(record.getDrugProportion());
				} else if (i == 3) {
					drugProportionMoreRecord.setItemName4(record.getOfficeName());
					drugProportionMoreRecord.setItemValue4(record.getDrugProportion());
				} else if (i == 4) {
					drugProportionMoreRecord.setItemName5(record.getOfficeName());
					drugProportionMoreRecord.setItemValue5(record.getDrugProportion());
				}

			}
			outHospStatisIndexInfo.setDrugProportionMoreRecord(drugProportionMoreRecord);

			// 耗占比比较少5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o1.getDisposableConsumableProportion().compareTo(o2.getDisposableConsumableProportion());
				}
			});
			OutHospStatisIndexItem disposableConsumableProportionLessRecord = new OutHospStatisIndexItem();
			for (int i = 0; i < newOutHospStatisIndexRecordList.size(); i++) {
				if (i > 4)
					continue;
				OutHospStatisIndexRecord record = newOutHospStatisIndexRecordList.get(i);

				if (i == 0) {
					disposableConsumableProportionLessRecord.setItemName1(record.getOfficeName());
					disposableConsumableProportionLessRecord.setItemValue1(record.getDisposableConsumableProportion());
				} else if (i == 1) {
					disposableConsumableProportionLessRecord.setItemName2(record.getOfficeName());
					disposableConsumableProportionLessRecord.setItemValue2(record.getDisposableConsumableProportion());
				} else if (i == 2) {
					disposableConsumableProportionLessRecord.setItemName3(record.getOfficeName());
					disposableConsumableProportionLessRecord.setItemValue3(record.getDisposableConsumableProportion());
				} else if (i == 3) {
					disposableConsumableProportionLessRecord.setItemName4(record.getOfficeName());
					disposableConsumableProportionLessRecord.setItemValue4(record.getDisposableConsumableProportion());
				} else if (i == 4) {
					disposableConsumableProportionLessRecord.setItemName5(record.getOfficeName());
					disposableConsumableProportionLessRecord.setItemValue5(record.getDisposableConsumableProportion());
				}

			}
			outHospStatisIndexInfo
					.setDisposableConsumableProportionLessRecord(disposableConsumableProportionLessRecord);

			// 耗占比比较多5科室
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getDisposableConsumableProportion().compareTo(o1.getDisposableConsumableProportion());
				}
			});
			OutHospStatisIndexItem disposableConsumableProportionMoreRecord = new OutHospStatisIndexItem();
			for (int i = 0; i < newOutHospStatisIndexRecordList.size(); i++) {
				if (i > 4)
					continue;
				OutHospStatisIndexRecord record = newOutHospStatisIndexRecordList.get(i);

				if (i == 0) {
					disposableConsumableProportionMoreRecord.setItemName1(record.getOfficeName());
					disposableConsumableProportionMoreRecord.setItemValue1(record.getDisposableConsumableProportion());
				} else if (i == 1) {
					disposableConsumableProportionMoreRecord.setItemName2(record.getOfficeName());
					disposableConsumableProportionMoreRecord.setItemValue2(record.getDisposableConsumableProportion());
				} else if (i == 2) {
					disposableConsumableProportionMoreRecord.setItemName3(record.getOfficeName());
					disposableConsumableProportionMoreRecord.setItemValue3(record.getDisposableConsumableProportion());
				} else if (i == 3) {
					disposableConsumableProportionMoreRecord.setItemName4(record.getOfficeName());
					disposableConsumableProportionMoreRecord.setItemValue4(record.getDisposableConsumableProportion());
				} else if (i == 4) {
					disposableConsumableProportionMoreRecord.setItemName5(record.getOfficeName());
					disposableConsumableProportionMoreRecord.setItemValue5(record.getDisposableConsumableProportion());
				}

			}
			outHospStatisIndexInfo
					.setDisposableConsumableProportionMoreRecord(disposableConsumableProportionMoreRecord);

			// 出院再入院
			Integer totalReInHospTotalNum = MapUtils.getInteger(repeatDeptKsMap, "totalCount");
			// 出院再入院
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getReOutHospInNum().compareTo(o1.getReOutHospInNum());
				}
			});

			OutHospStatisIndexItem reInHospNumRecord = new OutHospStatisIndexItem();
			reInHospNumRecord.setTotalNum(new BigDecimal(totalReInHospTotalNum.toString()));
			for (int i = 0; i < newOutHospStatisIndexRecordList.size(); i++) {
				if (i > 9)
					continue;
				OutHospStatisIndexRecord record = newOutHospStatisIndexRecordList.get(i);

				Integer reOutHospInNum = record.getReOutHospInNum();

				if (i == 0) {
					reInHospNumRecord.setItemName1(record.getOfficeName());
					reInHospNumRecord.setItemValue1(new BigDecimal(record.getReOutHospInNum().toString()));
				} else if (i == 1) {
					reInHospNumRecord.setItemName2(record.getOfficeName());
					reInHospNumRecord.setItemValue2(new BigDecimal(record.getReOutHospInNum().toString()));
				} else if (i == 2) {
					reInHospNumRecord.setItemName3(record.getOfficeName());
					reInHospNumRecord.setItemValue3(new BigDecimal(record.getReOutHospInNum().toString()));
				} else if (i == 3) {
					reInHospNumRecord.setItemName4(record.getOfficeName());
					reInHospNumRecord.setItemValue4(new BigDecimal(record.getReOutHospInNum().toString()));
				} else if (i == 4) {
					reInHospNumRecord.setItemName5(record.getOfficeName());
					reInHospNumRecord.setItemValue5(new BigDecimal(record.getReOutHospInNum().toString()));
				} else if (i == 5) {
					reInHospNumRecord.setItemName6(record.getOfficeName());
					reInHospNumRecord.setItemValue6(new BigDecimal(record.getReOutHospInNum().toString()));
				} else if (i == 6) {
					reInHospNumRecord.setItemName7(record.getOfficeName());
					reInHospNumRecord.setItemValue7(new BigDecimal(record.getReOutHospInNum().toString()));
				} else if (i == 7) {
					reInHospNumRecord.setItemName8(record.getOfficeName());
					reInHospNumRecord.setItemValue8(new BigDecimal(record.getReOutHospInNum().toString()));
				} else if (i == 8) {
					reInHospNumRecord.setItemName9(record.getOfficeName());
					reInHospNumRecord.setItemValue9(new BigDecimal(record.getReOutHospInNum().toString()));
				} else if (i == 9) {
					reInHospNumRecord.setItemName10(record.getOfficeName());
					reInHospNumRecord.setItemValue10(new BigDecimal(record.getReOutHospInNum().toString()));
				}

			}

			outHospStatisIndexInfo.setReInHospNumRecord(reInHospNumRecord);

			// 三四级治疗性操作占比
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return o2.getThirdForthSurgicalTherapeuticOpNumRate()
							.compareTo(o1.getThirdForthSurgicalTherapeuticOpNumRate());
				}
			});

			OutHospStatisIndexItem thirdForthSurgicalTherapeuticOpNumRateRecord = new OutHospStatisIndexItem();
			int thirdForthSurgicalTherapeuticOpNumRateIndex = 0;
			for (OutHospStatisIndexRecord record : newOutHospStatisIndexRecordList) {
				if (thirdForthSurgicalTherapeuticOpNumRateIndex > 4)
					continue;
				// 手术及治疗性操作人次数<20的科室不参与术前平均住院天数、术后平均住院天数、三四级手术及治疗性操作占比的排序
				if (record.getSurgicalTherapeuticOpNum() < 20)
					continue;

				if (thirdForthSurgicalTherapeuticOpNumRateIndex == 0) {
					thirdForthSurgicalTherapeuticOpNumRateRecord.setItemName1(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRateRecord
							.setItemValue1(record.getThirdForthSurgicalTherapeuticOpNumRate());
				} else if (thirdForthSurgicalTherapeuticOpNumRateIndex == 1) {
					thirdForthSurgicalTherapeuticOpNumRateRecord.setItemName2(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRateRecord
							.setItemValue2(record.getThirdForthSurgicalTherapeuticOpNumRate());
				} else if (thirdForthSurgicalTherapeuticOpNumRateIndex == 2) {
					thirdForthSurgicalTherapeuticOpNumRateRecord.setItemName3(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRateRecord
							.setItemValue3(record.getThirdForthSurgicalTherapeuticOpNumRate());
				} else if (thirdForthSurgicalTherapeuticOpNumRateIndex == 3) {
					thirdForthSurgicalTherapeuticOpNumRateRecord.setItemName4(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRateRecord
							.setItemValue4(record.getThirdForthSurgicalTherapeuticOpNumRate());
				} else if (thirdForthSurgicalTherapeuticOpNumRateIndex == 4) {
					thirdForthSurgicalTherapeuticOpNumRateRecord.setItemName5(record.getOfficeName());
					thirdForthSurgicalTherapeuticOpNumRateRecord
							.setItemValue5(record.getThirdForthSurgicalTherapeuticOpNumRate());
				}
				thirdForthSurgicalTherapeuticOpNumRateIndex++;

			}
			outHospStatisIndexInfo
					.setThirdForthSurgicalTherapeuticOpNumRateRecord(thirdForthSurgicalTherapeuticOpNumRateRecord);

			// 按照科室排序
			Collections.sort(newOutHospStatisIndexRecordList, new Comparator<OutHospStatisIndexRecord>() {

				@Override
				public int compare(OutHospStatisIndexRecord o1, OutHospStatisIndexRecord o2) {
					return Integer.parseInt(o1.getOfficeCode()) - Integer.parseInt(o2.getOfficeCode());
				}
			});

			// 集合信息
			outHospStatisIndexInfo.setOutHospStatisIndexRecordList(newOutHospStatisIndexRecordList);

		} catch (Exception e) {
			e.printStackTrace();
		}

		return outHospStatisIndexInfo;

	}

	public static Map<String, Integer> countRepeatInHospNumByDept(List<RepeatInHosp> repeatInHospList) {
		Map<String, List<RepeatInHosp>> map = new HashMap<String, List<RepeatInHosp>>();
		Map<String, Integer> mapKs = new HashMap<String, Integer>();
		List<RepeatInHosp> list = null;
		int totalCount = 0;

		for (RepeatInHosp btj : repeatInHospList) {
			String banum = btj.getMrId();
			list = map.get(banum);
			if (list != null) {
				list.add(btj);
			} else {
				list = new ArrayList<RepeatInHosp>();
				list.add(btj);
				map.put(banum, list);
			}
		}
		Iterator<Map.Entry<String, List<RepeatInHosp>>> it = map.entrySet().iterator();

		int shiwuzzy = 0;// 二到十五天在住院
		int erdaosanshiyizzy = 0;// 十六到三十一
		int sanshiyizzy = 0;// 三十一天以内
		while (it.hasNext()) {
			Map.Entry<String, List<RepeatInHosp>> entry = it.next();

			if (entry.getValue().size() <= 1) {
				it.remove();
			} else {
				List<RepeatInHosp> jlist = entry.getValue();

				Collections.sort(jlist, new Comparator<RepeatInHosp>() {
					public int compare(RepeatInHosp o1, RepeatInHosp o2) {
						/*
						 * Integer cs1 = o1.getZycs(); Integer cs2 = o2.getZycs(); if (cs1 != null &&
						 * cs2 != null) { return cs1 - cs2; } return 0;
						 */
						return o1.getOutTime().compareTo(o2.getOutTime());
					}
				});
				int listSize = jlist.size();
				for (int i = 0; i < listSize; i++) {
					// 上一次与下一次比较，用下面的减去上面的
					if (i == listSize - 1) {
						break;
					}
					int dangtianzzy = 0;// 当天在住院
					RepeatInHosp hou = jlist.get(i + 1);
					Date houruyuanTime = hou.getInTime();
					RepeatInHosp qian = jlist.get(i);
					Date qiancyTime = qian.getOutTime();
					String cyks = qian.getKsbm();
					Integer ksData = mapKs.get(cyks);
					Integer ksdangtianzzy = 0;
					if (ksData == null) {
						mapKs.put(cyks, ksdangtianzzy);
					} else {
						ksdangtianzzy = ksData;
					}
					int days = 0;
					if (houruyuanTime != null && qiancyTime != null) {
						days = DateUtil.getTimeDifferenceDays(houruyuanTime.getTime(), qiancyTime.getTime());
					}
					if (days <= 1 && days > 0) {
						ksdangtianzzy++;
						mapKs.put(cyks, ksdangtianzzy);
						totalCount++;
					}

				}
			}
		}

		mapKs.put("totalCount", totalCount);
		return mapKs;

	}

	/*
	 * public static Map<String, Integer>
	 * countRepeatInHospNumByDept(List<RepeatInHosp> repeatInHospList) { Map<String,
	 * Integer> repeatDeptKsMap = new HashMap<>(); try {
	 * 
	 * // 封装以mrId为key 对应的 repeatInHospList作为值 Map<String, List<RepeatInHosp>>
	 * mrIdRepeatListMap = new HashMap<>();
	 * 
	 * int count = 0;
	 * 
	 * List<RepeatInHosp> mrIdDeptList = null; for (RepeatInHosp repeatInHosp :
	 * repeatInHospList) { String mrId = repeatInHosp.getMrId(); if
	 * (mrIdRepeatListMap.get(mrId) != null) { mrIdDeptList =
	 * mrIdRepeatListMap.get(mrId); mrIdDeptList.add(repeatInHosp); } else {
	 * mrIdDeptList = new ArrayList<>(); mrIdDeptList.add(repeatInHosp);
	 * mrIdRepeatListMap.put(mrId, mrIdDeptList); } } for (Map.Entry<String,
	 * List<RepeatInHosp>> mrIdRepeatMap : mrIdRepeatListMap.entrySet()) {
	 * List<RepeatInHosp> repeatHospList = mrIdRepeatMap.getValue(); if
	 * (repeatHospList.size() > 1) { Collections.sort(repeatHospList, new
	 * Comparator<RepeatInHosp>() { public int compare(RepeatInHosp o1, RepeatInHosp
	 * o2) { return o1.getOutTime().compareTo(o2.getOutTime()); } });
	 * 
	 * int listSize = repeatHospList.size(); for (int i = 0; i < listSize; i++) { //
	 * 上一次与下一次比较，用下面的减去上面的 if (i == listSize - 1) { break; }
	 * 
	 * RepeatInHosp hou = repeatHospList.get(i + 1); Date houruyuanTime =
	 * hou.getInTime(); RepeatInHosp qian = repeatHospList.get(i); Date qianOutTime
	 * = qian.getOutTime();
	 * 
	 * int ksCount = 0; if (repeatDeptKsMap.get(hou.getKsbm()) == null) {
	 * repeatDeptKsMap.put(hou.getKsbm(), 0); } else { ksCount =
	 * MapUtils.getInteger(repeatDeptKsMap, hou.getKsbm()); }
	 * 
	 * int days = 0; if (houruyuanTime != null && qianOutTime != null) { days =
	 * DateUtil.getTimeDifferenceDays(houruyuanTime.getTime(),
	 * qianOutTime.getTime()); } if (days <= 1 && days > 0) { ksCount++; count++;
	 * repeatDeptKsMap.put(hou.getKsbm(), ksCount); }
	 * 
	 * } } }
	 * 
	 * repeatDeptKsMap.put("totalCount", count);
	 * 
	 * } catch (Exception e) { e.printStackTrace(); }
	 * 
	 * return repeatDeptKsMap; }
	 */

	/**
	 * 平均住院天数
	 * 
	 * @param month
	 * @param orgCode
	 * @return
	 */
	public AvgInHospDaysInfo getAvgInHospDays(StatisticalReportParam statisticalReportParam, String orgCode) {

		AvgInHospDaysInfo avgInHospDaysInfo = new AvgInHospDaysInfo();
		try {

			String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
			String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
			BigDecimal monthAvgInDays = getAvgInDays(startTime1 + " 00:00:00", endTime1 + "23:59:59", orgCode);
			String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
			String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
			BigDecimal preMonthAvgInDays = getAvgInDays(startTime2 + " 00:00:00", endTime2 + "23:59:59", orgCode);
			// 获取去年同期数据信息
			String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
			String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());
			BigDecimal lastYearMonthAvgInDays = getAvgInDays(startTime3 + " 00:00:00", endTime3 + "23:59:59", orgCode);
			avgInHospDaysInfo.setMonthInHospDays(monthAvgInDays.setScale(2, BigDecimal.ROUND_HALF_UP));
			avgInHospDaysInfo.setLastYearInHospDays(lastYearMonthAvgInDays.setScale(2, BigDecimal.ROUND_HALF_UP));
			avgInHospDaysInfo.setPreMonthInHospDays(preMonthAvgInDays.setScale(2, BigDecimal.ROUND_HALF_UP));

			String text = "    " + statisticalReportParam.getStatics1Name() + "平均住院天数为"
					+ monthAvgInDays.setScale(2, BigDecimal.ROUND_HALF_UP) + "天，比"
					+ statisticalReportParam.getStatics3Name() + "的"
					+ lastYearMonthAvgInDays.setScale(2, BigDecimal.ROUND_HALF_UP) + "天"
					+ BigDecimalUtil.getCompareResult(monthAvgInDays, lastYearMonthAvgInDays)
					+ BigDecimalUtil.getNumDifference(monthAvgInDays, lastYearMonthAvgInDays) + "天，"
					+ BigDecimalUtil.getCompareRateResult(monthAvgInDays, lastYearMonthAvgInDays) + "为"
					+ BigDecimalUtil.getCompareRate(monthAvgInDays, lastYearMonthAvgInDays) + "%；" + "比"
					+ statisticalReportParam.getStatics2Name() + "的"
					+ preMonthAvgInDays.setScale(2, BigDecimal.ROUND_HALF_UP) + "天"
					+ BigDecimalUtil.getCompareResult(monthAvgInDays, preMonthAvgInDays)
					+ BigDecimalUtil.getNumDifference(monthAvgInDays, preMonthAvgInDays) + "天，"
					+ BigDecimalUtil.getCompareRateResult(monthAvgInDays, preMonthAvgInDays) + "为"
					+ BigDecimalUtil.getCompareRate(monthAvgInDays, preMonthAvgInDays) + "%。";
			avgInHospDaysInfo.setText(text);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return avgInHospDaysInfo;

	}

	public BigDecimal getAvgInDays(String dateStr, String orgCode) throws ParseException {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
		Date date = df.parse(dateStr);
		Map<String, Object> firstLastDayStrMap = DateUtil.getFirstLastDayByMonth(date, "yyyy-MM-dd", true);
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setOrgCode(orgCode);
		mrInBasicQuery.setStartDateStr(MapUtils.getString(firstLastDayStrMap, "first"));
		mrInBasicQuery.setEndDateStr(MapUtils.getString(firstLastDayStrMap, "last"));
		return mrInBasicMapper.getAvgInHospDays(mrInBasicQuery);
	}

	public BigDecimal getAvgInDays(String startTimeStr, String endTimeStr, String orgCode) throws ParseException {
		/*
		 * SimpleDateFormat df = new SimpleDateFormat("yyyy-MM"); Date date =
		 * df.parse(dateStr); Map<String, Object> firstLastDayStrMap =
		 * DateUtil.getFirstLastDayByMonth(date, "yyyy-MM-dd", true);
		 *
		 */
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setOrgCode(orgCode);
		mrInBasicQuery.setStartDateStr(startTimeStr);
		mrInBasicQuery.setEndDateStr(endTimeStr);
		return mrInBasicMapper.getAvgInHospDays(mrInBasicQuery);
	}


	@Transactional(readOnly = true)
	@Override
	public OutPatientVisitInfo getOutpatientVisit(String orgCode, StatisticalReportParam statisticalReportParam) {

		OutPatientVisitInfo outPatientVisitInfo = new OutPatientVisitInfo();
		List<String> monthList = new LinkedList<>();
		monthList.add(statisticalReportParam.getStatics1Name());
		monthList.add(statisticalReportParam.getStatics2Name());
		monthList.add(statisticalReportParam.getStatics3Name());
		outPatientVisitInfo.setMonthList(monthList);

		try {

			List<String> outpatientMonths = DateUtil.getMonthBetween(statisticalReportParam.getStatics1StartTime(),
					statisticalReportParam.getStatics1EndTime());

			OutpatientVisit outpatientVisit = this.getTotalOutpatientVisit(outpatientMonths, orgCode);

			List<String> outpatientPreMonths = DateUtil.getMonthBetween(statisticalReportParam.getStatics2StartTime(),
					statisticalReportParam.getStatics2EndTime());

			OutpatientVisit preMonthOutpatientVisit = this.getTotalOutpatientVisit(outpatientPreMonths, orgCode);

			List<String> outpatientPreYearMonths = DateUtil.getMonthBetween(
					statisticalReportParam.getStatics3StartTime(), statisticalReportParam.getStatics3EndTime());

			OutpatientVisit preYearOutpatientVisit = this.getTotalOutpatientVisit(outpatientPreYearMonths, orgCode);

			if (outpatientVisit == null || preMonthOutpatientVisit == null || preYearOutpatientVisit == null) {
				return outPatientVisitInfo;
			}
			String summary = "    " + statisticalReportParam.getStatics1Name() + "，全院总诊疗人次数与"
					+ statisticalReportParam.getStatics3Name() + "相比"
					+ BigDecimalUtil.getCompareUpDowm(outpatientVisit.getTotalConsulNum(),
							preYearOutpatientVisit.getTotalConsulNum())
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getTotalConsulNum(),
							preYearOutpatientVisit.getTotalConsulNum())
					+ "%，" + "其中，门急诊人次数比" + statisticalReportParam.getStatics3Name() + ""
					+ BigDecimalUtil.getCompareUpDowm(outpatientVisit.getOutAndEmergNum(),
							preYearOutpatientVisit.getOutAndEmergNum())
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getOutAndEmergNum(),
							preYearOutpatientVisit.getOutAndEmergNum())
					+ "%，" + "普通门诊人次数与" + statisticalReportParam.getStatics3Name() + "相比"
					+ BigDecimalUtil.getCompareUpDowm(outpatientVisit.getOrdinaryOutNum(),
							preYearOutpatientVisit.getOrdinaryOutNum())
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getOrdinaryOutNum(),
							preYearOutpatientVisit.getOrdinaryOutNum())
					+ "%；" + "出院人数" + statisticalReportParam.getStatics3Name() + "相比"
					+ BigDecimalUtil.getCompareUpDowm(outpatientVisit.getOutNum(), preYearOutpatientVisit.getOutNum())
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getOutNum(), preYearOutpatientVisit.getOutNum())
					+ "%。详细分析如下：";

			outPatientVisitInfo.setSummary(summary);
			String text = "    " + statisticalReportParam.getStatics1Name() + "全院总诊疗人次数为"
					+ outpatientVisit.getTotalConsulNum() + "人次，比" + statisticalReportParam.getStatics3Name() + "的"
					+ preYearOutpatientVisit.getTotalConsulNum() + "人次"
					+ BigDecimalUtil.getCompareResult(outpatientVisit.getTotalConsulNum(),
							preYearOutpatientVisit.getTotalConsulNum())
					+ ""
					+ BigDecimalUtil.getNumDifference(
							outpatientVisit.getTotalConsulNum(), preYearOutpatientVisit.getTotalConsulNum(), true)
					+ "人次，"
					+ BigDecimalUtil.getCompareRateResult(outpatientVisit.getTotalConsulNum(),
							preYearOutpatientVisit.getTotalConsulNum())
					+ "为"
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getTotalConsulNum(),
							preYearOutpatientVisit.getTotalConsulNum())
					+ "%；比" + statisticalReportParam.getStatics2Name() + "的"
					+ preMonthOutpatientVisit.getTotalConsulNum() + "人次"
					+ BigDecimalUtil.getCompareResult(outpatientVisit.getTotalConsulNum(),
							preMonthOutpatientVisit.getTotalConsulNum())
					+ BigDecimalUtil.getNumDifference(
							outpatientVisit.getTotalConsulNum(), preMonthOutpatientVisit.getTotalConsulNum(), true)
					+ "人次，"
					+ BigDecimalUtil.getCompareRateResult(outpatientVisit.getTotalConsulNum(),
							preMonthOutpatientVisit.getTotalConsulNum())
					+ "为"
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getTotalConsulNum(),
							preMonthOutpatientVisit.getTotalConsulNum())
					+ "%。\n" + "    " + statisticalReportParam.getStatics1Name() + "门急诊人次数为"
					+ outpatientVisit.getOutAndEmergNum() + "人次，比" + statisticalReportParam.getStatics3Name() + "的"
					+ preYearOutpatientVisit.getOutAndEmergNum() + "人次"
					+ BigDecimalUtil.getCompareResult(outpatientVisit.getOutAndEmergNum(),
							preYearOutpatientVisit.getOutAndEmergNum())
					+ ""
					+ BigDecimalUtil.getNumDifference(
							outpatientVisit.getOutAndEmergNum(), preYearOutpatientVisit.getOutAndEmergNum(), true)
					+ "人次，"
					+ BigDecimalUtil.getCompareRateResult(outpatientVisit.getOutAndEmergNum(),
							preYearOutpatientVisit.getOutAndEmergNum())
					+ "为"
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getOutAndEmergNum(),
							preYearOutpatientVisit.getOutAndEmergNum())
					+ "%；比" + statisticalReportParam.getStatics2Name() + "的"
					+ preMonthOutpatientVisit.getOutAndEmergNum() + "人次"
					+ BigDecimalUtil.getCompareResult(outpatientVisit.getOutAndEmergNum(),
							preMonthOutpatientVisit.getOutAndEmergNum())
					+ BigDecimalUtil.getNumDifference(
							outpatientVisit.getOutAndEmergNum(), preMonthOutpatientVisit.getOutAndEmergNum(), true)
					+ "人次，"
					+ BigDecimalUtil.getCompareRateResult(outpatientVisit.getOutAndEmergNum(),
							preMonthOutpatientVisit.getOutAndEmergNum())
					+ "为"
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getOutAndEmergNum(),
							preMonthOutpatientVisit.getOutAndEmergNum())
					+ "%。\n" + "    " + statisticalReportParam.getStatics1Name() + "预约诊疗人次数为"
					+ outpatientVisit.getAppointmentNum() + "人次，比" + statisticalReportParam.getStatics3Name() + "的"
					+ preYearOutpatientVisit.getAppointmentNum() + "人次"
					+ BigDecimalUtil.getCompareResult(outpatientVisit.getAppointmentNum(),
							preYearOutpatientVisit.getAppointmentNum())
					+ ""
					+ BigDecimalUtil.getNumDifference(
							outpatientVisit.getAppointmentNum(), preYearOutpatientVisit.getAppointmentNum(), true)
					+ "人次，"
					+ BigDecimalUtil.getCompareRateResult(outpatientVisit.getAppointmentNum(),
							preYearOutpatientVisit.getAppointmentNum())
					+ "为"
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getAppointmentNum(),
							preYearOutpatientVisit.getAppointmentNum())
					+ "%；比" + statisticalReportParam.getStatics2Name() + "的"
					+ preMonthOutpatientVisit.getAppointmentNum() + "人次"
					+ BigDecimalUtil.getCompareResult(outpatientVisit.getAppointmentNum(),
							preMonthOutpatientVisit.getAppointmentNum())
					+ ""
					+ BigDecimalUtil.getNumDifference(
							outpatientVisit.getAppointmentNum(), preMonthOutpatientVisit.getAppointmentNum(), true)
					+ "人次，"
					+ BigDecimalUtil.getCompareRateResult(outpatientVisit.getAppointmentNum(),
							preMonthOutpatientVisit.getAppointmentNum())
					+ "为"
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getAppointmentNum(),
							preMonthOutpatientVisit.getAppointmentNum())
					+ "%。\n" + "    " + statisticalReportParam.getStatics1Name() + "普通门诊人次数为"
					+ outpatientVisit.getOrdinaryOutNum() + "人次，比" + statisticalReportParam.getStatics3Name() + "的"
					+ preYearOutpatientVisit.getOrdinaryOutNum() + "人次"
					+ BigDecimalUtil.getCompareResult(outpatientVisit.getOrdinaryOutNum(),
							preYearOutpatientVisit.getOrdinaryOutNum())
					+ ""
					+ BigDecimalUtil.getNumDifference(
							outpatientVisit.getOrdinaryOutNum(), preYearOutpatientVisit.getOrdinaryOutNum(), true)
					+ "人次，"
					+ BigDecimalUtil.getCompareRateResult(outpatientVisit.getOrdinaryOutNum(),
							preYearOutpatientVisit.getOrdinaryOutNum())
					+ "为"
					+ BigDecimalUtil.getCompareRate(outpatientVisit.getOrdinaryOutNum(),
							preYearOutpatientVisit.getOrdinaryOutNum())
					+ "%；比" + statisticalReportParam.getStatics2Name() + "的"
					+ preMonthOutpatientVisit.getOrdinaryOutNum() + "人次"
					+ BigDecimalUtil.getCompareResult(outpatientVisit.getOrdinaryOutNum(),
							preMonthOutpatientVisit.getOrdinaryOutNum())
					+ ""
					+ BigDecimalUtil.getNumDifference(
							outpatientVisit.getOrdinaryOutNum(), preMonthOutpatientVisit.getOrdinaryOutNum(), true)
					+ "人次，"
					+ BigDecimalUtil.getCompareRateResult(outpatientVisit.getOrdinaryOutNum(),
							preMonthOutpatientVisit.getOrdinaryOutNum())
					+ "为" + BigDecimalUtil.getCompareRate(outpatientVisit.getOrdinaryOutNum(),
							preMonthOutpatientVisit.getOrdinaryOutNum())
					+ "%（图1）。";
			outPatientVisitInfo.setOutPatientVisitText(text);

			List<BigDecimal> totalConsulNumList = new LinkedList<>();
			totalConsulNumList.add(outpatientVisit.getTotalConsulNum());
			totalConsulNumList.add(preYearOutpatientVisit.getTotalConsulNum());
			totalConsulNumList.add(preMonthOutpatientVisit.getTotalConsulNum());
			outPatientVisitInfo.setTotalConsulNumList(totalConsulNumList);

			List<BigDecimal> outAndEmergNumList = new LinkedList<>();
			outAndEmergNumList.add(outpatientVisit.getOutAndEmergNum());
			outAndEmergNumList.add(preYearOutpatientVisit.getOutAndEmergNum());
			outAndEmergNumList.add(preMonthOutpatientVisit.getOutAndEmergNum());
			outPatientVisitInfo.setOutAndEmergNumList(outAndEmergNumList);

			List<BigDecimal> appointmentNumList = new LinkedList<>();
			appointmentNumList.add(outpatientVisit.getAppointmentNum());
			appointmentNumList.add(preYearOutpatientVisit.getAppointmentNum());
			appointmentNumList.add(preMonthOutpatientVisit.getAppointmentNum());
			outPatientVisitInfo.setAppointmentNumList(appointmentNumList);

			List<BigDecimal> ordinaryOutNumList = new LinkedList<>();
			ordinaryOutNumList.add(outpatientVisit.getOrdinaryOutNum());
			ordinaryOutNumList.add(preYearOutpatientVisit.getOrdinaryOutNum());
			ordinaryOutNumList.add(preMonthOutpatientVisit.getOrdinaryOutNum());
			outPatientVisitInfo.setOrdinaryOutNumList(ordinaryOutNumList);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return outPatientVisitInfo;
	}

	public OutpatientVisit getTotalOutpatientVisit(List<String> months, String orgCode) {
		OutpatientVisit totalOutpatientVisit = new OutpatientVisit();
		OutpatientVisit subOutpatientVisit = null;
		BigDecimal totalConsulNum = new BigDecimal(0);// 总诊疗人数
		BigDecimal outAndEmergNum = new BigDecimal(0);// 门诊和急诊人次数（人次）
		BigDecimal appointmentNum = new BigDecimal(0);// 预约诊疗人次数（人次）
		BigDecimal ordinaryOutNum = new BigDecimal(0);// 普通门诊人次数（人次）
		BigDecimal outNum = new BigDecimal(0); // 出院人数
		BigDecimal deathNum = new BigDecimal(0);

		for (String month : months) {
			subOutpatientVisit = mrInBasicMapper.getOutpatientVisit(orgCode, month);
			totalConsulNum = totalConsulNum.add(new BigDecimal(subOutpatientVisit.getTotalConsulNum().toString()));
			outAndEmergNum = outAndEmergNum.add(new BigDecimal(subOutpatientVisit.getOutAndEmergNum().toString()));
			appointmentNum = appointmentNum.add(new BigDecimal(subOutpatientVisit.getAppointmentNum().toString()));
			ordinaryOutNum = ordinaryOutNum.add(new BigDecimal(subOutpatientVisit.getOrdinaryOutNum().toString()));
			outNum = outNum.add(new BigDecimal(subOutpatientVisit.getOutNum().toString()));
			deathNum = deathNum.add(new BigDecimal(subOutpatientVisit.getDeathNum().toString()));
		}
		totalOutpatientVisit.setAppointmentNum(appointmentNum);
		totalOutpatientVisit.setDeathNum(deathNum);
		totalOutpatientVisit.setOrdinaryOutNum(ordinaryOutNum);
		totalOutpatientVisit.setOutAndEmergNum(outAndEmergNum);
		totalOutpatientVisit.setOutNum(outNum);
		totalOutpatientVisit.setTotalConsulNum(totalConsulNum);

		return totalOutpatientVisit;

	}

	public String getMonthStr(String month) {
		String year = month.split("-")[0];
		String mon = month.split("-")[1];

		return year + "年" + mon + "月";
	}

	@Transactional(readOnly = true)
	@Override
	public BedIndexInfo getBedIndexInfo(String orgCode, StatisticalReportParam statisticalReportParam) {

		BedIndexInfo bedIndexInfo = new BedIndexInfo();

		try {

			List<String> months = DateUtil.getMonthBetween(statisticalReportParam.getStatics1StartTime(),
					statisticalReportParam.getStatics1EndTime());
			List<String> preMonths = DateUtil.getMonthBetween(statisticalReportParam.getStatics2StartTime(),
					statisticalReportParam.getStatics2EndTime());
			List<String> lastMonths = DateUtil.getMonthBetween(statisticalReportParam.getStatics3StartTime(),
					statisticalReportParam.getStatics3EndTime());

			BedIndex bedIndex = this.getTotalBedIndex(months, orgCode);

			BedIndex preYearBedIndex = this.getTotalBedIndex(lastMonths, orgCode);

			BedIndex preMonthBedIndex = this.getTotalBedIndex(preMonths, orgCode);

			System.out.println(bedIndex);
			// ----------------------------------床位周转率------------------------------------------------
			BigDecimal bedRotationRate = BigDecimalUtil.getDivide(bedIndex.getOutPersonNum(), bedIndex.getRealBeds());

			// 去年床位周转率
			BigDecimal preYearBedRotationRate = BigDecimalUtil.getDivide(preYearBedIndex.getOutPersonNum(),
					preYearBedIndex.getRealBeds());

			// 上月床位周转率
			BigDecimal preMonthBedRotationRate = BigDecimalUtil.getDivide(preMonthBedIndex.getOutPersonNum(),
					preMonthBedIndex.getRealBeds());

			// ----------------------------------床位使用率------------------------------
			BigDecimal bedUseRate = BigDecimalUtil.getDivideRate(bedIndex.getActualUseBedDays(),
					bedIndex.getActualAvailableBedDays());

			BigDecimal preYearBedUseRate = BigDecimalUtil.getDivideRate(preYearBedIndex.getActualUseBedDays(),
					preYearBedIndex.getActualAvailableBedDays());

			BigDecimal preMonthBedUseRate = BigDecimalUtil.getDivideRate(preMonthBedIndex.getActualUseBedDays(),
					preMonthBedIndex.getActualAvailableBedDays());
			System.out.println(bedUseRate + "--" + preYearBedUseRate + "--" + preMonthBedUseRate);

			String bedIndexText = "    " + statisticalReportParam.getStatics1Name() + "床位周转率（次）为" + bedRotationRate
					+ "次，比" + statisticalReportParam.getStatics3Name() + "的" + preYearBedRotationRate + "次"
					+ BigDecimalUtil.getCompareResult(bedRotationRate, preYearBedRotationRate) + ""
					+ BigDecimalUtil.getNumDifference(bedRotationRate, preYearBedRotationRate) + "，"
					+ BigDecimalUtil.getCompareRateResult(bedRotationRate, preYearBedRotationRate) + "为"
					+ BigDecimalUtil.getCompareRate(bedRotationRate, preYearBedRotationRate) + "%；比"
					+ statisticalReportParam.getStatics2Name() + "的" + preMonthBedRotationRate + "次"
					+ BigDecimalUtil.getCompareResult(bedRotationRate, preMonthBedRotationRate) + ""
					+ BigDecimalUtil.getNumDifference(bedRotationRate, preMonthBedRotationRate) + "，"
					+ BigDecimalUtil.getCompareRateResult(bedRotationRate, preMonthBedRotationRate) + "为"
					+ BigDecimalUtil.getCompareRate(bedRotationRate, preMonthBedRotationRate) + "%。\n" + "    "
					+ statisticalReportParam.getStatics1Name() + "床位使用率" + bedUseRate + "%，比"
					+ statisticalReportParam.getStatics3Name() + "的" + preYearBedUseRate + "%"
					+ BigDecimalUtil.getCompareResult(bedUseRate, preYearBedUseRate) + ""
					+ BigDecimalUtil.getNumDifference(bedUseRate, preYearBedUseRate) + "%，"
					+ BigDecimalUtil.getCompareRateResult(bedUseRate, preYearBedUseRate) + "为"
					+ BigDecimalUtil.getCompareRate(bedUseRate, preYearBedUseRate) + "%；比"
					+ statisticalReportParam.getStatics2Name() + "的" + preMonthBedUseRate + "%"
					+ BigDecimalUtil.getCompareResult(bedUseRate, preMonthBedUseRate) + ""
					+ BigDecimalUtil.getNumDifference(bedUseRate, preMonthBedUseRate) + "%，"
					+ BigDecimalUtil.getCompareRateResult(bedUseRate, preMonthBedUseRate) + "为"
					+ BigDecimalUtil.getCompareRate(bedUseRate, preMonthBedUseRate) + "%。";

			bedIndexInfo.setBedIndexText(bedIndexText);

			List<BedIndexRecord> bedIndexRecordList = new LinkedList<>();

			BedIndexRecord bedIndexRecord1 = new BedIndexRecord();
			bedIndexRecord1.setTitle(statisticalReportParam.getStatics1Name());
			bedIndexRecord1.setRealBeds(bedIndex.getRealBeds().toString());
			bedIndexRecord1.setActualAvailableBedDays(bedIndex.getActualAvailableBedDays().toString());
			bedIndexRecord1.setActualUseBedDays(bedIndex.getActualUseBedDays().toString());
			bedIndexRecord1.setDischargedBedDays(bedIndex.getDischargedBedDays().toString());
			bedIndexRecord1.setBedRoateRate(bedRotationRate.toString());
			bedIndexRecord1.setBedUseRate(bedUseRate.toString());
			bedIndexRecordList.add(bedIndexRecord1);

			BedIndexRecord bedIndexRecord2 = new BedIndexRecord();
			bedIndexRecord2.setTitle(statisticalReportParam.getStatics3Name());
			bedIndexRecord2.setRealBeds(preYearBedIndex.getRealBeds().toString());
			bedIndexRecord2.setActualAvailableBedDays(preYearBedIndex.getActualAvailableBedDays().toString());
			bedIndexRecord2.setActualUseBedDays(preYearBedIndex.getActualUseBedDays().toString());
			bedIndexRecord2.setDischargedBedDays(preYearBedIndex.getDischargedBedDays().toString());
			bedIndexRecord2.setBedRoateRate(preYearBedRotationRate.toString());
			bedIndexRecord2.setBedUseRate(preYearBedUseRate.toString());
			bedIndexRecordList.add(bedIndexRecord2);

			BedIndexRecord bedIndexRecord3 = new BedIndexRecord();
			bedIndexRecord3.setTitle(statisticalReportParam.getStatics2Name());
			bedIndexRecord3.setRealBeds(preMonthBedIndex.getRealBeds().toString());
			bedIndexRecord3.setActualAvailableBedDays(preMonthBedIndex.getActualAvailableBedDays().toString());
			bedIndexRecord3.setActualUseBedDays(preMonthBedIndex.getActualUseBedDays().toString());
			bedIndexRecord3.setDischargedBedDays(preMonthBedIndex.getDischargedBedDays().toString());
			bedIndexRecord3.setBedRoateRate(preMonthBedRotationRate.toString());
			bedIndexRecord3.setBedUseRate(preMonthBedUseRate.toString());
			bedIndexRecordList.add(bedIndexRecord3);

			BedIndexRecord bedIndexRecord4 = new BedIndexRecord();
			bedIndexRecord4.setTitle("比同期增减");
			bedIndexRecord4.setRealBeds(
					BigDecimalUtil.getSubtract(bedIndex.getRealBeds(), preYearBedIndex.getRealBeds(), 0).toString());
			bedIndexRecord4.setActualAvailableBedDays(BigDecimalUtil
					.getSubtract(bedIndex.getActualAvailableBedDays(), preYearBedIndex.getActualAvailableBedDays(), 0)
					.toString());
			bedIndexRecord4.setActualUseBedDays(BigDecimalUtil
					.getSubtract(bedIndex.getActualUseBedDays(), preYearBedIndex.getActualUseBedDays(), 0).toString());
			bedIndexRecord4.setDischargedBedDays(BigDecimalUtil
					.getSubtract(bedIndex.getDischargedBedDays(), preYearBedIndex.getDischargedBedDays(), 0)
					.toString());

			System.out.println(bedRotationRate + "----" + preYearBedRotationRate);
			bedIndexRecord4
					.setBedRoateRate(BigDecimalUtil.getSubtract(bedRotationRate, preYearBedRotationRate, 2).toString());
			bedIndexRecord4.setBedUseRate(BigDecimalUtil.getSubtract(bedUseRate, preYearBedUseRate, 2).toString());
			bedIndexRecordList.add(bedIndexRecord4);

			BedIndexRecord bedIndexRecord5 = new BedIndexRecord();
			bedIndexRecord5.setTitle("比同期变化率（%）");
			bedIndexRecord5.setRealBeds(
					BigDecimalUtil.getCompareRate(bedIndex.getRealBeds(), preYearBedIndex.getRealBeds(), 2).toString());
			bedIndexRecord5
					.setActualAvailableBedDays(BigDecimalUtil.getCompareRate(bedIndex.getActualAvailableBedDays(),
							preYearBedIndex.getActualAvailableBedDays(), 2).toString());
			bedIndexRecord5.setActualUseBedDays(BigDecimalUtil
					.getCompareRate(bedIndex.getActualUseBedDays(), preYearBedIndex.getActualUseBedDays(), 2)
					.toString());
			bedIndexRecord5.setDischargedBedDays(BigDecimalUtil
					.getCompareRate(bedIndex.getDischargedBedDays(), preYearBedIndex.getDischargedBedDays(), 2)
					.toString());
			bedIndexRecord5.setBedRoateRate(
					BigDecimalUtil.getCompareRate(bedRotationRate, preYearBedRotationRate, 2).toString());
			bedIndexRecord5.setBedUseRate(BigDecimalUtil.getCompareRate(bedUseRate, preYearBedUseRate, 2).toString());
			bedIndexRecordList.add(bedIndexRecord5);

			BedIndexRecord bedIndexRecord6 = new BedIndexRecord();
			bedIndexRecord6.setTitle("比上月增减");
			bedIndexRecord6.setRealBeds(
					BigDecimalUtil.getSubtract(bedIndex.getRealBeds(), preMonthBedIndex.getRealBeds(), 0).toString());
			bedIndexRecord6.setActualAvailableBedDays(BigDecimalUtil
					.getSubtract(bedIndex.getActualAvailableBedDays(), preMonthBedIndex.getActualAvailableBedDays(), 0)
					.toString());
			bedIndexRecord6.setActualUseBedDays(BigDecimalUtil
					.getSubtract(bedIndex.getActualUseBedDays(), preMonthBedIndex.getActualUseBedDays(), 0).toString());
			bedIndexRecord6.setDischargedBedDays(BigDecimalUtil
					.getSubtract(bedIndex.getDischargedBedDays(), preMonthBedIndex.getDischargedBedDays(), 0)
					.toString());
			bedIndexRecord6.setBedRoateRate(
					BigDecimalUtil.getSubtract(bedRotationRate, preMonthBedRotationRate, 2).toString());
			bedIndexRecord6.setBedUseRate(BigDecimalUtil.getSubtract(bedUseRate, preMonthBedUseRate, 2).toString());
			bedIndexRecordList.add(bedIndexRecord6);

			BedIndexRecord bedIndexRecord7 = new BedIndexRecord();
			bedIndexRecord7.setTitle("比上月变化率（%）");
			bedIndexRecord7.setRealBeds(BigDecimalUtil
					.getCompareRate(bedIndex.getRealBeds(), preMonthBedIndex.getRealBeds(), 2).toString());
			bedIndexRecord7
					.setActualAvailableBedDays(BigDecimalUtil.getCompareRate(bedIndex.getActualAvailableBedDays(),
							preMonthBedIndex.getActualAvailableBedDays(), 2).toString());
			bedIndexRecord7.setActualUseBedDays(BigDecimalUtil
					.getCompareRate(bedIndex.getActualUseBedDays(), preMonthBedIndex.getActualUseBedDays(), 2)
					.toString());
			bedIndexRecord7.setDischargedBedDays(BigDecimalUtil
					.getCompareRate(bedIndex.getDischargedBedDays(), preMonthBedIndex.getDischargedBedDays(), 2)
					.toString());
			bedIndexRecord7.setBedRoateRate(
					BigDecimalUtil.getCompareRate(bedRotationRate, preMonthBedRotationRate, 2).toString());
			bedIndexRecord7.setBedUseRate(BigDecimalUtil.getCompareRate(bedUseRate, preMonthBedUseRate, 2).toString());
			bedIndexRecordList.add(bedIndexRecord7);

			bedIndexInfo.setBedIndexRecordList(bedIndexRecordList);

		} catch (Exception e) {
			e.printStackTrace();
		}

		return bedIndexInfo;

	}

	public BedIndex getTotalBedIndex(List<String> months, String orgCode) {
		BedIndex totalBedIndex = new BedIndex();
		BedIndex bedIndex = null;
		BigDecimal totalRealBeds = new BigDecimal(0);
		;// 实有床位数

		BigDecimal totalActualAvailableBedDays = new BigDecimal(0);// 实际占用总床日数 （日）

		BigDecimal totalActualUseBedDays = new BigDecimal(0);// 实际占用总床日数 （日）

		BigDecimal totalDischargedBedDays = new BigDecimal(0);// 出院者占用总床日数

		BigDecimal totalOutPersonNum = new BigDecimal(0);// 出院人数

		int totalDays = 0;
		
		for (String month : months) {
		//要注意转义字符：“.”和“|”都是转义字符，必须得加"\\"。同理：*和+也是如此的
			int monthDays = DateUtil.getMonthDays(Integer.parseInt(month.split("\\.")[0]), Integer.parseInt(month.split("\\.")[1]));
			totalDays+=monthDays;
			bedIndex = mrInBasicMapper.getBedIndex(orgCode, month);
			totalRealBeds = totalRealBeds.add(new BigDecimal(bedIndex.getRealBeds().intValue()).multiply(new BigDecimal(monthDays)));
			totalActualAvailableBedDays = totalActualAvailableBedDays
					.add(new BigDecimal(bedIndex.getActualAvailableBedDays().intValue()));
			totalActualUseBedDays = totalActualUseBedDays
					.add(new BigDecimal(bedIndex.getActualUseBedDays().intValue()));
			totalDischargedBedDays = totalDischargedBedDays
					.add(new BigDecimal(bedIndex.getDischargedBedDays().intValue()));
			totalOutPersonNum = totalOutPersonNum.add(new BigDecimal(bedIndex.getOutPersonNum().intValue()));

		}
		totalBedIndex.setRealBeds(totalRealBeds.divide(new BigDecimal(totalDays) , 0, BigDecimal.ROUND_HALF_UP));
		totalBedIndex.setActualAvailableBedDays(totalActualAvailableBedDays);
		totalBedIndex.setActualUseBedDays(totalActualUseBedDays);
		totalBedIndex.setDischargedBedDays(totalDischargedBedDays);
		totalBedIndex.setOutPersonNum(totalOutPersonNum);

		return totalBedIndex;

	}
	
	

	@Transactional(readOnly = true)
	@Override
	public OutNumDeathRateInfo getOutNumAndDeathRate(StatisticalReportParam statisticalReportParam, String orgCode) {

		OutNumDeathRateInfo outNumDeathRateInfo = new OutNumDeathRateInfo();

		try {

			List<String> monthList = new LinkedList<>();
			monthList.add(statisticalReportParam.getStatics1Name());

			// 去年同月日期
			monthList.add(statisticalReportParam.getStatics3Name());
			// 上月日期
			monthList.add(statisticalReportParam.getStatics2Name());

			outNumDeathRateInfo.setMonthList(monthList);
			
			

			/*
			 * List<String> months =
			 * DateUtil.getMonthBetween(statisticalReportParam.getStatics1StartTime(),
			 * statisticalReportParam.getStatics1EndTime()); List<String> preMonths =
			 * DateUtil.getMonthBetween(statisticalReportParam.getStatics2StartTime(),
			 * statisticalReportParam.getStatics2EndTime()); List<String> lastMonths =
			 * DateUtil.getMonthBetween(statisticalReportParam.getStatics3StartTime(),
			 * statisticalReportParam.getStatics3EndTime());
			 */

			String startTime1 = DateUtil.dateFormat("yyyy-MM-dd",statisticalReportParam.getStatics1StartTime());
			String endTime1 = DateUtil.dateFormat("yyyy-MM-dd",statisticalReportParam.getStatics1EndTime());
			OutpatientVisit outpatientVisit = mrInBasicMapper.getOutAndDeathNum(startTime1+" 00:00:00",endTime1+" 23:59:59" ,orgCode);

			String startTime2 = DateUtil.dateFormat("yyyy-MM-dd",statisticalReportParam.getStatics2StartTime());
			String endTime2 = DateUtil.dateFormat("yyyy-MM-dd",statisticalReportParam.getStatics2EndTime());
			OutpatientVisit preMonthOutpatientVisit = mrInBasicMapper.getOutAndDeathNum(startTime2+" 00:00:00",endTime2+" 23:59:59" ,orgCode);

			String startTime3 = DateUtil.dateFormat("yyyy-MM-dd",statisticalReportParam.getStatics3StartTime());
			String endTime3 = DateUtil.dateFormat("yyyy-MM-dd",statisticalReportParam.getStatics3EndTime());
			OutpatientVisit preYearOutpatientVisit = mrInBasicMapper.getOutAndDeathNum(startTime3+" 00:00:00",endTime3+" 23:59:59" ,orgCode);

			if (outpatientVisit != null && preMonthOutpatientVisit != null && preYearOutpatientVisit != null) {

				BigDecimal deathRate = BigDecimalUtil.getDivideRate(outpatientVisit.getDeathNum(),
						outpatientVisit.getOutNum());

				BigDecimal preYearDeathRate = BigDecimalUtil.getDivideRate(preYearOutpatientVisit.getDeathNum(),
						preYearOutpatientVisit.getOutNum());

				BigDecimal preMonthDeathRate = BigDecimalUtil.getDivideRate(preMonthOutpatientVisit.getDeathNum(),
						preMonthOutpatientVisit.getOutNum());

				String outNumDeathRateText = "    " + statisticalReportParam.getStatics1Name() + "出院人数为"
						+ outpatientVisit.getOutNum() + "人，比" + statisticalReportParam.getStatics3Name() + "的"
						+ preYearOutpatientVisit.getOutNum() + "人"
						+ BigDecimalUtil.getCompareResult(outpatientVisit.getOutNum(),
								preYearOutpatientVisit.getOutNum())
						+ BigDecimalUtil
								.getNumDifference(outpatientVisit.getOutNum(), preYearOutpatientVisit.getOutNum(), true)
						+ "人，"
						+ BigDecimalUtil.getCompareRateResult(outpatientVisit.getOutNum(),
								preYearOutpatientVisit.getOutNum())
						+ "为"
						+ BigDecimalUtil.getCompareRate(outpatientVisit.getOutNum(), preYearOutpatientVisit.getOutNum())
						+ "%；比" + statisticalReportParam.getStatics2Name() + "的" + preMonthOutpatientVisit.getOutNum()
						+ "人"
						+ BigDecimalUtil.getCompareResult(outpatientVisit.getOutNum(),
								preMonthOutpatientVisit.getOutNum())
						+ BigDecimalUtil.getNumDifference(outpatientVisit.getOutNum(),
								preMonthOutpatientVisit.getOutNum(), true)
						+ "人，"
						+ BigDecimalUtil
								.getCompareRateResult(outpatientVisit.getOutNum(), preMonthOutpatientVisit.getOutNum())
						+ "为"
						+ BigDecimalUtil.getCompareRate(outpatientVisit.getOutNum(),
								preMonthOutpatientVisit.getOutNum())
						+ "%（图2）。\n" + "    " + statisticalReportParam.getStatics1Name() + "出院患者死亡率为" + deathRate
						+ "%，比" + statisticalReportParam.getStatics3Name() + "的" + preYearDeathRate + "%"
						+ BigDecimalUtil.getCompareResult(deathRate, preYearDeathRate)
						+ BigDecimalUtil.getNumDifference(deathRate, preYearDeathRate) + "%，"
						+ BigDecimalUtil.getCompareRateResult(deathRate, preYearDeathRate) + "为"
						+ BigDecimalUtil.getCompareRate(deathRate, preYearDeathRate) + "%；比"
						+ statisticalReportParam.getStatics2Name() + "的" + preMonthDeathRate + "%"
						+ BigDecimalUtil.getCompareResult(deathRate, preMonthDeathRate)
						+ BigDecimalUtil.getNumDifference(deathRate, preMonthDeathRate) + "%，"
						+ BigDecimalUtil.getCompareRateResult(deathRate, preMonthDeathRate) + "为"
						+ BigDecimalUtil.getCompareRate(deathRate, preMonthDeathRate) + "%。";

				outNumDeathRateInfo.setOutNumDeathRateText(outNumDeathRateText);

				List<BigDecimal> outNumList = new LinkedList<>();
				outNumList.add(outpatientVisit.getOutNum());
				outNumList.add(preYearOutpatientVisit.getOutNum());
				outNumList.add(preMonthOutpatientVisit.getOutNum());
				outNumDeathRateInfo.setOutNumList(outNumList);

				List<BigDecimal> deathRateList = new LinkedList<>();
				deathRateList.add(deathRate);
				deathRateList.add(preYearDeathRate);
				deathRateList.add(preMonthDeathRate);
				outNumDeathRateInfo.setDeathRateList(deathRateList);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return outNumDeathRateInfo;

	}

	@Override
	public void getmajorDiseaseOperation(String params, String orgCode) {

		String[] majorDiagArr = { "急性心肌梗死", "充血性心力衰竭", "脑出血和脑梗塞", "创伤性颅脑损伤", "消化道出血", "累及身体多个部位的损伤", "肺炎(成人)",
				"慢性阻塞性肺疾病", "糖尿病伴短期并发症", "糖尿病伴长期并发症", "结节性甲状腺肿", "急性阑尾炎伴弥漫性腹膜炎及脓肿", "前列腺增生", "肾衰竭", "败血症", "高血压病",
				"急性胰腺炎", "恶性肿瘤化疗" };

		List<String> majorDiagList = Arrays.asList(majorDiagArr);

		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
		Date date = null;
		try {
			date = df.parse(params);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Map<String, Object> firstLastDayStrMap = DateUtil.getFirstLastDayByMonth(date, "yyyy-MM-dd", true);

		List<TTjBzfl> tTjBzflList = mrInBasicMapper.getTjBzflByBzType(orgCode);
		for (TTjBzfl jbfl : tTjBzflList) {
			if (!majorDiagList.contains(jbfl.getName())) {
				continue;
			}

			Integer count = 0;
			String order = jbfl.getYuliu2();
			String bztype = jbfl.getType();
			String jb_lei = jbfl.getLeimu();
			String jb_ya = jbfl.getYamu();
			String jb_xi = jbfl.getXimu();
			String zdtype = jbfl.getYuliu3();
			String num = jbfl.getYuliu1();
			String name = jbfl.getName();
			String companion = jbfl.getCompanion();
			boolean jbzdFirstState = false;// 默认没有设置过，一旦设置过开头就要加or

			StringBuffer sql_1 = new StringBuffer();
			sql_1.append(" exists(");
			sql_1.append("select id from mr_in_diagnoss d where ");
			sql_1.append(" d.diag_type in(").append(zdtype).append(") ");
			if (StringUtil.isKeYongStr(jb_lei) || StringUtil.isKeYongStr(jb_ya) || StringUtil.isKeYongStr(jb_xi)) {
				sql_1.append(" and (");
			}
			if (StringUtil.isKeYongStr(jb_lei)) {
				sql_1.append(StringUtil.getDouhaoFengeForSql_HouLike("d.diag_code", jb_lei));
				jbzdFirstState = true;
			}
			if (StringUtil.isKeYongStr(jb_ya)) {
				if (jbzdFirstState) {
					sql_1.append("  or ");
				}
				sql_1.append(StringUtil.getDouhaoFengeForSql_HouLike("d.diag_code", jb_ya)).append("");
				jbzdFirstState = true;
			}
			if (StringUtil.isKeYongStr(jb_xi)) {
				if (jbzdFirstState) {
					sql_1.append("  or ");
				}
				sql_1.append(StringUtil.getDouhaoFengeForSql("d.diag_code", jb_xi)).append("");
				jbzdFirstState = true;

			}
			if (StringUtil.isKeYongStr(jb_lei) || StringUtil.isKeYongStr(jb_ya) || StringUtil.isKeYongStr(jb_xi)) {
				sql_1.append(" )");
			}

			sql_1.append(" and d.serial_number=base.id");
			sql_1.append(" ) ");
			// 判断非产妇 20180712更改手术原：(o.ops_code like '72%' OR (o.ops_code>'73.0' and
			// o.ops_code<'73.3' ) ");
			// sql_1.append(" OR ( o.ops_code>'73.4' and o.ops_code <'74') ");
			if ("1.1".equals(bztype) || "1.2".equals(bztype) || "1.3".equals(bztype) || "1.4".equals(bztype)
					|| "1.5".equals(bztype) || "1.8".equals(bztype)) {

				sql_1.append(" and not (  ");
				sql_1.append(" ((exists( ");
				sql_1.append(
						" select id from mr_in_diagnoss d where (d.diag_code like 'O80%' OR  d.diag_code like 'O81%' OR  d.diag_code like 'O82%' ");
				sql_1.append(" OR  d.diag_code like 'O83%'  OR  d.diag_code like 'O84%'  ");

				sql_1.append(" ) and d.diag_type in('22','23') and d.serial_number=base.id ");
				sql_1.append(" ) ");
				sql_1.append(" or exists( ");
				sql_1.append(
						" select id from  mr_in_operation o where o.ops_sign in('21','11')  and o.serial_number=base.id");
				sql_1.append(
						" and ((o.ops_code>'72.0' and o.ops_code<'72.80' ) OR  (o.ops_code>'73.0' and o.ops_code<'73.22' ) ");
				sql_1.append(" OR ( o.ops_code>'73.4' and  o.ops_code <'73.95') ");
				sql_1.append(" )");
				sql_1.append(" )");
				sql_1.append(" )");
				sql_1.append(" and exists( ");
				sql_1.append(
						" select id from mr_in_diagnoss d where d.diag_code like 'Z37%' and d.diag_type in('22','23') and d.serial_number=base.id ");
				sql_1.append(" ) ");
				sql_1.append(" )  ");
				// 新添加20180712
				sql_1.append(" and exists( ");
				sql_1.append(
						" select id from  mr_in_operation o where o.ops_sign in('21','11')  and o.serial_number=base.id");
				sql_1.append(" and ((o.ops_code>'74' and o.ops_code<'74.5' ) OR  (o.ops_code like '74.99%' ) )");

				sql_1.append(" ))");

			}

			// 非心脏病手术住院患者
			if ("1.1".equals(bztype) || "1.2".equals(bztype)) {
				sql_1.append(" and not exists( ");
				sql_1.append(
						" select id from mr_in_operation o where o.ops_sign in('21','11') and o.ops_code>'35' and o.ops_code<'40' and o.serial_number=base.id ");
				sql_1.append("  ) ");
			}

			// 男性患者
			if ("1.6".equals(bztype)) {
				sql_1.append("and base.sex='1'");
			}

			// 判断成人
			if ("1.8".equals(bztype)) {
				sql_1.append("and base.age_year>=18");
			}
			// 判断儿童
			if ("1.7".equals(bztype)) {
				// sql_1.append(" and to_number( to_date(to_char(base.in_time ,'yyyy-mm-dd')
				// ,'yyyy-mm-dd')-");

				// sql_1.append(" to_date(to_char(base.birthday ,'yyyy-mm-dd') ,'yyyy-mm-dd') )
				// >=28 and base.age_year<18 ");
				sql_1.append("  and base.age_year>=1 and base.age_year<18 ");
			}
			// 判断合并症
			if (companion != null) {
				sql_1.append("and exists(");
				sql_1.append("select id from mr_in_diagnoss d where ");
				sql_1.append(" d.diag_type in('22','23') and ");

				if (StringUtil.isKeYongStr(companion)) {
					sql_1.append(StringUtil.getDouhaoFengeForSql_HouLike("d.diag_code", companion));
					jbzdFirstState = true;
				}

				sql_1.append(" and d.serial_number=base.id");
				sql_1.append(" ) ");

			}

			String start = MapUtils.getString(firstLastDayStrMap, "first");

			String last = MapUtils.getString(firstLastDayStrMap, "last");

			System.out.println(start + "--" + last + "--" + orgCode);

			List<Map<String, Object>> baseForTjList = mrInBasicMapper.getFocalPoint(start.split(" ")[0],
					last.split(" ")[0], sql_1.toString(), orgCode);

			System.out.println(baseForTjList);
		}

		System.out.println(tTjBzflList);

	}

	@Override
	public OutpatientSatisfactionInfo getOutpatientSatisfaction(StatisticalReportParam statisticalReportParam,
			String orgCode) {

		String startTime = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());

		String endTime = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());

		FeelOdStatistics feelOdStatistics = feelOdSphMapper.feelOdStatistics(startTime + " 00:00:00",
				endTime + " 23:59:59", orgCode);

		OutpatientSatisfactionInfo outpatientSatisfactionInfo = new OutpatientSatisfactionInfo();
		List<OutpatientSatisfactionRecord> outpatientSatisfactionRecordList = new LinkedList<>();

		if (feelOdStatistics != null) {
			feelOdStatistics.initData(feelOdStatistics);

			// 您对此次就诊的总体评价
			OutpatientSatisfactionRecord outpatientSatisfactionRecord = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord.setDesc("您对此次就诊的总体评价");
			outpatientSatisfactionRecord.setVerySatisfied(feelOdStatistics.getSph43_verysatisfiedLv() != null
					? feelOdStatistics.getSph43_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord.setSatisfied(
					feelOdStatistics.getSph43_satisfiedLv() != null ? feelOdStatistics.getSph43_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord.setGeneralSatisfied(
					feelOdStatistics.getSph43_generalLv() != null ? feelOdStatistics.getSph43_generalLv().toString()
							: null);
			outpatientSatisfactionRecord.setNoSatisfied(feelOdStatistics.getSph43_dissatisfiedLv() != null
					? feelOdStatistics.getSph43_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord.setVeryNoSatisfied(feelOdStatistics.getSph43_verydissatisfiedLv() != null
					? feelOdStatistics.getSph43_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord);

			// 门诊大厅导医台导诊人员为您提供的指引服务满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord1 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord1.setDesc("门诊大厅导医台导诊人员为您提供的指引服务满意吗？");
			outpatientSatisfactionRecord1.setVerySatisfied(feelOdStatistics.getSph05_verysatisfiedLv() != null
					? feelOdStatistics.getSph05_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord1.setSatisfied(
					feelOdStatistics.getSph05_satisfiedLv() != null ? feelOdStatistics.getSph05_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord1.setGeneralSatisfied(
					feelOdStatistics.getSph05_generalLv() != null ? feelOdStatistics.getSph05_generalLv().toString()
							: null);
			outpatientSatisfactionRecord1.setNoSatisfied(feelOdStatistics.getSph05_dissatisfiedLv() != null
					? feelOdStatistics.getSph05_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord1.setVeryNoSatisfied(feelOdStatistics.getSph05_verydissatisfiedLv() != null
					? feelOdStatistics.getSph05_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord1);
			// 您认为门诊就医的引导设施（如各楼层的指示牌或路标）清晰准确吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord2 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord2.setDesc("您认为门诊就医的引导设施（如各楼层的指示牌或路标）清晰准确吗？");
			outpatientSatisfactionRecord2.setVerySatisfied(feelOdStatistics.getSph07_verysatisfiedLv() != null
					? feelOdStatistics.getSph07_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord2.setSatisfied(
					feelOdStatistics.getSph07_satisfiedLv() != null ? feelOdStatistics.getSph07_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord2.setGeneralSatisfied(
					feelOdStatistics.getSph07_generalLv() != null ? feelOdStatistics.getSph07_generalLv().toString()
							: null);
			outpatientSatisfactionRecord2.setNoSatisfied(feelOdStatistics.getSph07_dissatisfiedLv() != null
					? feelOdStatistics.getSph07_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord2.setVeryNoSatisfied(feelOdStatistics.getSph07_verydissatisfiedLv() != null
					? feelOdStatistics.getSph07_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord2);
			// 您认为医院公布的当天门诊医生个人信息、出诊信息准确吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord3 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord3.setDesc("您认为医院公布的当天门诊医生个人信息、出诊信息准确吗？");
			outpatientSatisfactionRecord3.setVerySatisfied(feelOdStatistics.getSph08_verysatisfiedLv() != null
					? feelOdStatistics.getSph08_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord3.setSatisfied(
					feelOdStatistics.getSph08_satisfiedLv() != null ? feelOdStatistics.getSph08_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord3.setGeneralSatisfied(
					feelOdStatistics.getSph08_generalLv() != null ? feelOdStatistics.getSph08_generalLv().toString()
							: null);
			outpatientSatisfactionRecord3.setNoSatisfied(feelOdStatistics.getSph08_dissatisfiedLv() != null
					? feelOdStatistics.getSph08_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord3.setVeryNoSatisfied(feelOdStatistics.getSph08_verydissatisfiedLv() != null
					? feelOdStatistics.getSph08_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord3);

			// 您对就诊等候区秩序满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord4 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord4.setDesc("您对就诊等候区秩序满意吗？");
			outpatientSatisfactionRecord4.setVerySatisfied(feelOdStatistics.getSph12_verysatisfiedLv() != null
					? feelOdStatistics.getSph12_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord4.setSatisfied(
					feelOdStatistics.getSph12_satisfiedLv() != null ? feelOdStatistics.getSph12_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord4.setGeneralSatisfied(
					feelOdStatistics.getSph12_generalLv() != null ? feelOdStatistics.getSph12_generalLv().toString()
							: null);
			outpatientSatisfactionRecord4.setNoSatisfied(feelOdStatistics.getSph12_dissatisfiedLv() != null
					? feelOdStatistics.getSph12_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord4.setVeryNoSatisfied(feelOdStatistics.getSph12_verydissatisfiedLv() != null
					? feelOdStatistics.getSph12_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord4);

			// 您对医生询问病情和检查的耐心细致程度满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord5 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord5.setDesc("您对医生询问病情和检查的耐心细致程度满意吗？");
			outpatientSatisfactionRecord5.setVerySatisfied(feelOdStatistics.getSph15_verysatisfiedLv() != null
					? feelOdStatistics.getSph15_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord5.setSatisfied(
					feelOdStatistics.getSph15_satisfiedLv() != null ? feelOdStatistics.getSph15_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord5.setGeneralSatisfied(
					feelOdStatistics.getSph15_generalLv() != null ? feelOdStatistics.getSph15_generalLv().toString()
							: null);
			outpatientSatisfactionRecord5.setNoSatisfied(feelOdStatistics.getSph15_dissatisfiedLv() != null
					? feelOdStatistics.getSph15_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord5.setVeryNoSatisfied(feelOdStatistics.getSph15_verydissatisfiedLv() != null
					? feelOdStatistics.getSph15_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord5);

			// 您对医生解释告知检查结果、治疗方案及用药计划满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord6 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord6.setDesc("您对医生解释告知检查结果、治疗方案及用药计划满意吗？");
			outpatientSatisfactionRecord6.setVerySatisfied(feelOdStatistics.getSph16_verysatisfiedLv() != null
					? feelOdStatistics.getSph16_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord6.setSatisfied(
					feelOdStatistics.getSph16_satisfiedLv() != null ? feelOdStatistics.getSph16_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord6.setGeneralSatisfied(
					feelOdStatistics.getSph16_generalLv() != null ? feelOdStatistics.getSph16_generalLv().toString()
							: null);
			outpatientSatisfactionRecord6.setNoSatisfied(feelOdStatistics.getSph16_dissatisfiedLv() != null
					? feelOdStatistics.getSph16_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord6.setVeryNoSatisfied(feelOdStatistics.getSph16_verydissatisfiedLv() != null
					? feelOdStatistics.getSph16_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord6);

			// 在门诊诊断或治疗时，您对医务人员关注并保护您的隐私满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord7 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord7.setDesc("在门诊诊断或治疗时，您对医务人员关注并保护您的隐私满意吗？");
			outpatientSatisfactionRecord7.setVerySatisfied(feelOdStatistics.getSph17_verysatisfiedLv() != null
					? feelOdStatistics.getSph17_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord7.setSatisfied(
					feelOdStatistics.getSph17_satisfiedLv() != null ? feelOdStatistics.getSph17_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord7.setGeneralSatisfied(
					feelOdStatistics.getSph17_generalLv() != null ? feelOdStatistics.getSph17_generalLv().toString()
							: null);
			outpatientSatisfactionRecord7.setNoSatisfied(feelOdStatistics.getSph17_dissatisfiedLv() != null
					? feelOdStatistics.getSph17_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord7.setVeryNoSatisfied(feelOdStatistics.getSph17_verydissatisfiedLv() != null
					? feelOdStatistics.getSph17_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord7);

			// 您对门诊检验科检查等候时间满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord8 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord8.setDesc("您对门诊检验科检查等候时间满意吗？");
			outpatientSatisfactionRecord8.setVerySatisfied(feelOdStatistics.getSph18_verysatisfiedLv() != null
					? feelOdStatistics.getSph18_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord8.setSatisfied(
					feelOdStatistics.getSph18_satisfiedLv() != null ? feelOdStatistics.getSph18_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord8.setGeneralSatisfied(
					feelOdStatistics.getSph18_generalLv() != null ? feelOdStatistics.getSph18_generalLv().toString()
							: null);
			outpatientSatisfactionRecord8.setNoSatisfied(feelOdStatistics.getSph18_dissatisfiedLv() != null
					? feelOdStatistics.getSph18_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord8.setVeryNoSatisfied(feelOdStatistics.getSph18_verydissatisfiedLv() != null
					? feelOdStatistics.getSph18_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord8);

			// 您对门诊放射X光检查等候时间满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord9 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord9.setDesc("您对门诊放射X光检查等候时间满意吗？");
			outpatientSatisfactionRecord9.setVerySatisfied(feelOdStatistics.getSph20_verysatisfiedLv() != null
					? feelOdStatistics.getSph20_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord9.setSatisfied(
					feelOdStatistics.getSph20_satisfiedLv() != null ? feelOdStatistics.getSph20_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord9.setGeneralSatisfied(
					feelOdStatistics.getSph20_generalLv() != null ? feelOdStatistics.getSph20_generalLv().toString()
							: null);
			outpatientSatisfactionRecord9.setNoSatisfied(feelOdStatistics.getSph20_dissatisfiedLv() != null
					? feelOdStatistics.getSph20_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord9.setVeryNoSatisfied(feelOdStatistics.getSph20_verydissatisfiedLv() != null
					? feelOdStatistics.getSph20_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord9);

			// 您对放射X光检查出报告时间满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord10 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord10.setDesc("您对放射X光检查出报告时间满意吗？");
			outpatientSatisfactionRecord10.setVerySatisfied(feelOdStatistics.getSph21_verysatisfiedLv() != null
					? feelOdStatistics.getSph21_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord10.setSatisfied(
					feelOdStatistics.getSph21_satisfiedLv() != null ? feelOdStatistics.getSph21_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord10.setGeneralSatisfied(
					feelOdStatistics.getSph21_generalLv() != null ? feelOdStatistics.getSph21_generalLv().toString()
							: null);
			outpatientSatisfactionRecord10.setNoSatisfied(feelOdStatistics.getSph21_dissatisfiedLv() != null
					? feelOdStatistics.getSph21_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord10.setVeryNoSatisfied(feelOdStatistics.getSph21_verydissatisfiedLv() != null
					? feelOdStatistics.getSph21_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord10);

			// 您对门诊CT检查等候时间满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord11 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord11.setDesc("您对门诊CT检查等候时间满意吗？");
			outpatientSatisfactionRecord11.setVerySatisfied(feelOdStatistics.getSph23_verysatisfiedLv() != null
					? feelOdStatistics.getSph23_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord11.setSatisfied(
					feelOdStatistics.getSph23_satisfiedLv() != null ? feelOdStatistics.getSph23_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord11.setGeneralSatisfied(
					feelOdStatistics.getSph23_generalLv() != null ? feelOdStatistics.getSph23_generalLv().toString()
							: null);
			outpatientSatisfactionRecord11.setNoSatisfied(feelOdStatistics.getSph23_dissatisfiedLv() != null
					? feelOdStatistics.getSph23_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord11.setVeryNoSatisfied(feelOdStatistics.getSph23_verydissatisfiedLv() != null
					? feelOdStatistics.getSph23_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord11);

			// 您对CT检查出报告时间满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord12 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord12.setDesc("您对CT检查出报告时间满意吗？");
			outpatientSatisfactionRecord12.setVerySatisfied(feelOdStatistics.getSph24_verysatisfiedLv() != null
					? feelOdStatistics.getSph24_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord12.setSatisfied(
					feelOdStatistics.getSph24_satisfiedLv() != null ? feelOdStatistics.getSph24_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord12.setGeneralSatisfied(
					feelOdStatistics.getSph24_generalLv() != null ? feelOdStatistics.getSph24_generalLv().toString()
							: null);
			outpatientSatisfactionRecord12.setNoSatisfied(feelOdStatistics.getSph24_dissatisfiedLv() != null
					? feelOdStatistics.getSph24_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord12.setVeryNoSatisfied(feelOdStatistics.getSph24_verydissatisfiedLv() != null
					? feelOdStatistics.getSph24_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord12);

			// 您对门诊放射MRI检查等候时间满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord13 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord13.setDesc("您对门诊放射MRI检查等候时间满意吗？");
			outpatientSatisfactionRecord13.setVerySatisfied(feelOdStatistics.getSph26_verysatisfiedLv() != null
					? feelOdStatistics.getSph26_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord13.setSatisfied(
					feelOdStatistics.getSph26_satisfiedLv() != null ? feelOdStatistics.getSph26_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord13.setGeneralSatisfied(
					feelOdStatistics.getSph26_generalLv() != null ? feelOdStatistics.getSph26_generalLv().toString()
							: null);
			outpatientSatisfactionRecord13.setNoSatisfied(feelOdStatistics.getSph26_dissatisfiedLv() != null
					? feelOdStatistics.getSph26_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord13.setVeryNoSatisfied(feelOdStatistics.getSph26_verydissatisfiedLv() != null
					? feelOdStatistics.getSph26_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord13);

			// 您对放射MRI检查出报告时间满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord14 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord14.setDesc("您对放射MRI检查出报告时间满意吗？");
			outpatientSatisfactionRecord14.setVerySatisfied(feelOdStatistics.getSph27_verysatisfiedLv() != null
					? feelOdStatistics.getSph27_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord14.setSatisfied(
					feelOdStatistics.getSph27_satisfiedLv() != null ? feelOdStatistics.getSph27_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord14.setGeneralSatisfied(
					feelOdStatistics.getSph27_generalLv() != null ? feelOdStatistics.getSph27_generalLv().toString()
							: null);
			outpatientSatisfactionRecord14.setNoSatisfied(feelOdStatistics.getSph27_dissatisfiedLv() != null
					? feelOdStatistics.getSph27_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord14.setVeryNoSatisfied(feelOdStatistics.getSph27_verydissatisfiedLv() != null
					? feelOdStatistics.getSph27_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord14);

			// 您对放射MRI检查出报告时间满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord15 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord15.setDesc("您对放射MRI检查出报告时间满意吗？");
			outpatientSatisfactionRecord15.setVerySatisfied(feelOdStatistics.getSph29_verysatisfiedLv() != null
					? feelOdStatistics.getSph29_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord15.setSatisfied(
					feelOdStatistics.getSph29_satisfiedLv() != null ? feelOdStatistics.getSph29_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord15.setGeneralSatisfied(
					feelOdStatistics.getSph29_generalLv() != null ? feelOdStatistics.getSph29_generalLv().toString()
							: null);
			outpatientSatisfactionRecord15.setNoSatisfied(feelOdStatistics.getSph29_dissatisfiedLv() != null
					? feelOdStatistics.getSph29_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord15.setVeryNoSatisfied(feelOdStatistics.getSph29_verydissatisfiedLv() != null
					? feelOdStatistics.getSph29_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord15);

			// 您对超声科检查出报告时间满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord16 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord16.setDesc("您对超声科检查出报告时间满意吗？");
			outpatientSatisfactionRecord16.setVerySatisfied(feelOdStatistics.getSph30_verysatisfiedLv() != null
					? feelOdStatistics.getSph30_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord16.setSatisfied(
					feelOdStatistics.getSph30_satisfiedLv() != null ? feelOdStatistics.getSph30_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord16.setGeneralSatisfied(
					feelOdStatistics.getSph30_generalLv() != null ? feelOdStatistics.getSph30_generalLv().toString()
							: null);
			outpatientSatisfactionRecord16.setNoSatisfied(feelOdStatistics.getSph30_dissatisfiedLv() != null
					? feelOdStatistics.getSph30_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord16.setVeryNoSatisfied(feelOdStatistics.getSph30_verydissatisfiedLv() != null
					? feelOdStatistics.getSph30_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord16);

			// 您对医护人员的咨询服务满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord17 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord17.setDesc("您对医护人员的咨询服务满意吗？");
			outpatientSatisfactionRecord17.setVerySatisfied(feelOdStatistics.getSph31_verysatisfiedLv() != null
					? feelOdStatistics.getSph31_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord17.setSatisfied(
					feelOdStatistics.getSph31_satisfiedLv() != null ? feelOdStatistics.getSph31_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord17.setGeneralSatisfied(
					feelOdStatistics.getSph31_generalLv() != null ? feelOdStatistics.getSph31_generalLv().toString()
							: null);
			outpatientSatisfactionRecord17.setNoSatisfied(feelOdStatistics.getSph31_dissatisfiedLv() != null
					? feelOdStatistics.getSph31_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord17.setVeryNoSatisfied(feelOdStatistics.getSph31_verydissatisfiedLv() != null
					? feelOdStatistics.getSph31_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord17);

			// 您对门诊提供的健康宣教服务满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord18 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord18.setDesc("您对门诊提供的健康宣教服务满意吗？");
			outpatientSatisfactionRecord18.setVerySatisfied(feelOdStatistics.getSph32_verysatisfiedLv() != null
					? feelOdStatistics.getSph32_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord18.setSatisfied(
					feelOdStatistics.getSph32_satisfiedLv() != null ? feelOdStatistics.getSph32_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord18.setGeneralSatisfied(
					feelOdStatistics.getSph32_generalLv() != null ? feelOdStatistics.getSph32_generalLv().toString()
							: null);
			outpatientSatisfactionRecord18.setNoSatisfied(feelOdStatistics.getSph32_dissatisfiedLv() != null
					? feelOdStatistics.getSph32_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord18.setVeryNoSatisfied(feelOdStatistics.getSph32_verydissatisfiedLv() != null
					? feelOdStatistics.getSph32_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord18);

			// 您对门诊提供的轮椅服务满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord19 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord19.setDesc("您对门诊提供的轮椅服务满意吗？");
			outpatientSatisfactionRecord19.setVerySatisfied(feelOdStatistics.getSph37_verysatisfiedLv() != null
					? feelOdStatistics.getSph37_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord19.setSatisfied(
					feelOdStatistics.getSph37_satisfiedLv() != null ? feelOdStatistics.getSph37_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord19.setGeneralSatisfied(
					feelOdStatistics.getSph37_generalLv() != null ? feelOdStatistics.getSph37_generalLv().toString()
							: null);
			outpatientSatisfactionRecord19.setNoSatisfied(feelOdStatistics.getSph37_dissatisfiedLv() != null
					? feelOdStatistics.getSph37_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord19.setVeryNoSatisfied(feelOdStatistics.getSph37_verydissatisfiedLv() != null
					? feelOdStatistics.getSph37_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord19);

			// 您对医院门诊卫生间的卫生状况和设施配备满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord20 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord20.setDesc("您对医院门诊卫生间的卫生状况和设施配备满意吗？");
			outpatientSatisfactionRecord20.setVerySatisfied(feelOdStatistics.getSph34_verysatisfiedLv() != null
					? feelOdStatistics.getSph34_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord20.setSatisfied(
					feelOdStatistics.getSph34_satisfiedLv() != null ? feelOdStatistics.getSph34_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord20.setGeneralSatisfied(
					feelOdStatistics.getSph34_generalLv() != null ? feelOdStatistics.getSph34_generalLv().toString()
							: null);
			outpatientSatisfactionRecord20.setNoSatisfied(feelOdStatistics.getSph34_dissatisfiedLv() != null
					? feelOdStatistics.getSph34_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord20.setVeryNoSatisfied(feelOdStatistics.getSph34_verydissatisfiedLv() != null
					? feelOdStatistics.getSph34_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord20);

			// 您对门诊环境卫生状况满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord21 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord21.setDesc("您对门诊环境卫生状况满意吗？");
			outpatientSatisfactionRecord21.setVerySatisfied(feelOdStatistics.getSph35_verysatisfiedLv() != null
					? feelOdStatistics.getSph35_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord21.setSatisfied(
					feelOdStatistics.getSph35_satisfiedLv() != null ? feelOdStatistics.getSph35_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord21.setGeneralSatisfied(
					feelOdStatistics.getSph35_generalLv() != null ? feelOdStatistics.getSph35_generalLv().toString()
							: null);
			outpatientSatisfactionRecord21.setNoSatisfied(feelOdStatistics.getSph35_dissatisfiedLv() != null
					? feelOdStatistics.getSph35_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord21.setVeryNoSatisfied(feelOdStatistics.getSph35_verydissatisfiedLv() != null
					? feelOdStatistics.getSph35_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord21);

			// 您对医院的安全保卫措施满意吗？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord22 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord22.setDesc("您对医院的安全保卫措施满意吗？");
			outpatientSatisfactionRecord22.setVerySatisfied(feelOdStatistics.getSph36_verysatisfiedLv() != null
					? feelOdStatistics.getSph36_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord22.setSatisfied(
					feelOdStatistics.getSph36_satisfiedLv() != null ? feelOdStatistics.getSph36_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord22.setGeneralSatisfied(
					feelOdStatistics.getSph36_generalLv() != null ? feelOdStatistics.getSph36_generalLv().toString()
							: null);
			outpatientSatisfactionRecord22.setNoSatisfied(feelOdStatistics.getSph36_dissatisfiedLv() != null
					? feelOdStatistics.getSph36_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord22.setVeryNoSatisfied(feelOdStatistics.getSph36_verydissatisfiedLv() != null
					? feelOdStatistics.getSph36_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord22);

			OutpatientSatisfactionRecord outpatientSatisfactionRecord23 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord23.setDesc(null);
			outpatientSatisfactionRecord23.setVerySatisfied("10分钟以内");
			outpatientSatisfactionRecord23.setSatisfied("10-15分钟");
			outpatientSatisfactionRecord23.setGeneralSatisfied("15-20分钟");
			outpatientSatisfactionRecord23.setNoSatisfied("20-30分钟");
			outpatientSatisfactionRecord23.setVeryNoSatisfied("30分钟以上");
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord23);

			// 您等候取药大约用了多长时间？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord24 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord24.setDesc("您等候取药大约用了多长时间？");
			outpatientSatisfactionRecord24.setVerySatisfied(feelOdStatistics.getSph33_verysatisfiedLv() != null
					? feelOdStatistics.getSph33_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord24.setSatisfied(
					feelOdStatistics.getSph33_satisfiedLv() != null ? feelOdStatistics.getSph33_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord24.setGeneralSatisfied(
					feelOdStatistics.getSph33_generalLv() != null ? feelOdStatistics.getSph33_generalLv().toString()
							: null);
			outpatientSatisfactionRecord24.setNoSatisfied(feelOdStatistics.getSph33_dissatisfiedLv() != null
					? feelOdStatistics.getSph33_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord24.setVeryNoSatisfied(feelOdStatistics.getSph33_verydissatisfiedLv() != null
					? feelOdStatistics.getSph33_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord24);

			// 从护士开始分诊，您等候分诊取号用了多长时间？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord25 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord25.setDesc("从护士开始分诊，您等候分诊取号用了多长时间？");
			outpatientSatisfactionRecord25.setVerySatisfied(feelOdStatistics.getSph09_verysatisfiedLv() != null
					? feelOdStatistics.getSph09_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord25.setSatisfied(
					feelOdStatistics.getSph09_satisfiedLv() != null ? feelOdStatistics.getSph09_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord25.setGeneralSatisfied(
					feelOdStatistics.getSph09_generalLv() != null ? feelOdStatistics.getSph09_generalLv().toString()
							: null);
			outpatientSatisfactionRecord25.setNoSatisfied(feelOdStatistics.getSph09_dissatisfiedLv() != null
					? feelOdStatistics.getSph09_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord25.setVeryNoSatisfied(feelOdStatistics.getSph09_verydissatisfiedLv() != null
					? feelOdStatistics.getSph09_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord25);

			// 您在缴费窗口缴费等候了多长时间？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord26 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord26.setDesc("您在缴费窗口缴费等候了多长时间？");
			outpatientSatisfactionRecord26.setVerySatisfied(feelOdStatistics.getSph10_verysatisfiedLv() != null
					? feelOdStatistics.getSph10_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord26.setSatisfied(
					feelOdStatistics.getSph10_satisfiedLv() != null ? feelOdStatistics.getSph10_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord26.setGeneralSatisfied(
					feelOdStatistics.getSph10_generalLv() != null ? feelOdStatistics.getSph10_generalLv().toString()
							: null);
			outpatientSatisfactionRecord26.setNoSatisfied(feelOdStatistics.getSph10_dissatisfiedLv() != null
					? feelOdStatistics.getSph10_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord26.setVeryNoSatisfied(feelOdStatistics.getSph10_verydissatisfiedLv() != null
					? feelOdStatistics.getSph10_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord26);

			// 从您的就诊小票上的候诊时间到医生呼叫到您的名字大约用了多长时间？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord27 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord27.setDesc("从您的就诊小票上的候诊时间到医生呼叫到您的名字大约用了多长时间？");
			outpatientSatisfactionRecord27.setVerySatisfied(feelOdStatistics.getSph13_verysatisfiedLv() != null
					? feelOdStatistics.getSph13_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord27.setSatisfied(
					feelOdStatistics.getSph13_satisfiedLv() != null ? feelOdStatistics.getSph13_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord27.setGeneralSatisfied(
					feelOdStatistics.getSph13_generalLv() != null ? feelOdStatistics.getSph13_generalLv().toString()
							: null);
			outpatientSatisfactionRecord27.setNoSatisfied(feelOdStatistics.getSph13_dissatisfiedLv() != null
					? feelOdStatistics.getSph13_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord27.setVeryNoSatisfied(feelOdStatistics.getSph13_verydissatisfiedLv() != null
					? feelOdStatistics.getSph13_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord27);

			OutpatientSatisfactionRecord outpatientSatisfactionRecord28 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord28.setDesc(null);
			outpatientSatisfactionRecord28.setVerySatisfied("超过10分钟");
			outpatientSatisfactionRecord28.setSatisfied("8-10分钟");
			outpatientSatisfactionRecord28.setGeneralSatisfied("5-8分钟");
			outpatientSatisfactionRecord28.setNoSatisfied("3-5分钟");
			outpatientSatisfactionRecord28.setVeryNoSatisfied("33分钟以内");
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord28);

			// 门诊医生为您看病大约用了多长时间？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord29 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord29.setDesc("门诊医生为您看病大约用了多长时间？");
			outpatientSatisfactionRecord29.setVerySatisfied(feelOdStatistics.getSph14_verysatisfiedLv() != null
					? feelOdStatistics.getSph14_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord29.setSatisfied(
					feelOdStatistics.getSph14_satisfiedLv() != null ? feelOdStatistics.getSph14_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord29.setGeneralSatisfied(
					feelOdStatistics.getSph14_generalLv() != null ? feelOdStatistics.getSph14_generalLv().toString()
							: null);
			outpatientSatisfactionRecord29.setNoSatisfied(feelOdStatistics.getSph14_dissatisfiedLv() != null
					? feelOdStatistics.getSph14_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord29.setVeryNoSatisfied(feelOdStatistics.getSph14_verydissatisfiedLv() != null
					? feelOdStatistics.getSph14_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord29);

			OutpatientSatisfactionRecord outpatientSatisfactionRecord30 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord30.setDesc(null);
			outpatientSatisfactionRecord30.setVerySatisfied("比预期要便宜");
			outpatientSatisfactionRecord30.setSatisfied("与预期相符");
			outpatientSatisfactionRecord30.setGeneralSatisfied("有点贵但能接受");
			outpatientSatisfactionRecord30.setNoSatisfied("很贵");
			outpatientSatisfactionRecord30.setVeryNoSatisfied("无法接受");
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord30);

			// 结合病情，您对此次就诊的费用接受程度是怎样的？
			OutpatientSatisfactionRecord outpatientSatisfactionRecord31 = new OutpatientSatisfactionRecord();
			outpatientSatisfactionRecord31.setDesc("结合病情，您对此次就诊的费用接受程度是怎样的？");
			outpatientSatisfactionRecord31.setVerySatisfied(feelOdStatistics.getSph38_verysatisfiedLv() != null
					? feelOdStatistics.getSph38_verysatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord31.setSatisfied(
					feelOdStatistics.getSph38_satisfiedLv() != null ? feelOdStatistics.getSph38_satisfiedLv().toString()
							: null);
			outpatientSatisfactionRecord31.setGeneralSatisfied(
					feelOdStatistics.getSph38_generalLv() != null ? feelOdStatistics.getSph38_generalLv().toString()
							: null);
			outpatientSatisfactionRecord31.setNoSatisfied(feelOdStatistics.getSph38_dissatisfiedLv() != null
					? feelOdStatistics.getSph38_dissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecord31.setVeryNoSatisfied(feelOdStatistics.getSph38_verydissatisfiedLv() != null
					? feelOdStatistics.getSph38_verydissatisfiedLv().toString()
					: null);
			outpatientSatisfactionRecordList.add(outpatientSatisfactionRecord31);

			String text = "     此表为" + statisticalReportParam.getStatics1Name() + "门诊患者满意度调查详情。患者对我院的总体情况的评价为很满意和满意的率为"
					+ feelOdStatistics.getSph43_verysatisfiedLv() + "%和" + feelOdStatistics.getSph43_satisfiedLv()
					+ "%，一般的为" + feelOdStatistics.getSph43_generalLv() + "%，不满意和很不满意的率分别为"
					+ feelOdStatistics.getSph43_dissatisfiedLv() + "%和" + feelOdStatistics.getSph43_verydissatisfiedLv()
					+ "%。";

			outpatientSatisfactionInfo.setStatistionText(text);

		}

		outpatientSatisfactionInfo.setOutpatientSatisfactionRecords(outpatientSatisfactionRecordList);

		return outpatientSatisfactionInfo;
	}

	public FeelOdStatistics getFeelOdStatistics(String startTime, String endTime, String orgCode)
			throws ParseException {

		FeelOdStatistics feelOdStatistics = feelOdSphMapper.feelOdStatistics(startTime + " 00:00:00",
				endTime + " 23:59:59", orgCode);
		if (feelOdStatistics != null) {
			feelOdStatistics.initData(feelOdStatistics);
		}

		return feelOdStatistics;
	}

	@Override
	public OutSatisContrastAnalysisInfo getOutSatisContrastAnalysisInfo(StatisticalReportParam statisticalReportParam,
			String orgCode) {

		OutSatisContrastAnalysisInfo outSatisContrastAnalysisInfo = new OutSatisContrastAnalysisInfo();

		List<OutSatisContrastAnalysisRecord> outSatisContrastAnalysisRecords = new LinkedList<>();

		List<OutSatisContrastAnalysisRecord> sortOutSatisContrastAnalysisRecords = new ArrayList<>();

		try {
			// 获取本月门诊满意度信息
			String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
			String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
			FeelOdStatistics feelOdStatistics = getFeelOdStatistics(startTime1, endTime1, orgCode);
			// 获取其他月满意度信息
			String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
			String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
			FeelOdStatistics otherFeelOdStatistics = getFeelOdStatistics(startTime2, endTime2, orgCode);

			if (feelOdStatistics == null || otherFeelOdStatistics == null) {
				return outSatisContrastAnalysisInfo;
			}

			// 您对此次就诊的总体评价
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord.setDesc("您对此次就诊的总体评价");

			double monthRate = NumUtil.add(feelOdStatistics.getSph43_verysatisfiedLv(),
					feelOdStatistics.getSph43_satisfiedLv(), feelOdStatistics.getSph43_generalLv());

			double otherMonthRate = NumUtil.add(otherFeelOdStatistics.getSph43_verysatisfiedLv(),
					otherFeelOdStatistics.getSph43_satisfiedLv(), otherFeelOdStatistics.getSph43_generalLv());

			outSatisContrastAnalysisRecord.setMonthRate(monthRate);
			outSatisContrastAnalysisRecord.setOthrtRate(otherMonthRate);
			outSatisContrastAnalysisRecord.setFluctuate(BigDecimalUtil.sub(monthRate, otherMonthRate));
			outSatisContrastAnalysisRecord.setRange(BigDecimalUtil.divide(monthRate, otherMonthRate));
			outSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord);

			// 门诊大厅导医台导诊人员为您提供的指引服务满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord1 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord1.setDesc("门诊大厅导医台导诊人员为您提供的指引服务满意吗？");

			double monthRate1 = NumUtil.add(feelOdStatistics.getSph05_verysatisfiedLv(),
					feelOdStatistics.getSph05_satisfiedLv(), feelOdStatistics.getSph05_generalLv());

			double otherMonthRate1 = NumUtil.add(otherFeelOdStatistics.getSph05_verysatisfiedLv(),
					otherFeelOdStatistics.getSph05_satisfiedLv(), otherFeelOdStatistics.getSph05_generalLv());

			outSatisContrastAnalysisRecord1.setMonthRate(monthRate1);
			outSatisContrastAnalysisRecord1.setOthrtRate(otherMonthRate1);
			outSatisContrastAnalysisRecord1.setFluctuate(BigDecimalUtil.sub(monthRate1, otherMonthRate1));
			outSatisContrastAnalysisRecord1.setRange(BigDecimalUtil.divide(monthRate1, otherMonthRate1));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord1);

			// 您认为门诊就医的引导设施（如各楼层的指示牌或路标）清晰准确吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord2 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord2.setDesc("您认为门诊就医的引导设施（如各楼层的指示牌或路标）清晰准确吗？");

			double monthRate2 = NumUtil.add(feelOdStatistics.getSph07_verysatisfiedLv(),
					feelOdStatistics.getSph07_satisfiedLv(), feelOdStatistics.getSph07_generalLv());

			double otherMonthRate2 = NumUtil.add(otherFeelOdStatistics.getSph07_verysatisfiedLv(),
					otherFeelOdStatistics.getSph07_satisfiedLv(), otherFeelOdStatistics.getSph07_generalLv());

			outSatisContrastAnalysisRecord2.setMonthRate(monthRate2);
			outSatisContrastAnalysisRecord2.setOthrtRate(otherMonthRate2);
			outSatisContrastAnalysisRecord2.setFluctuate(BigDecimalUtil.sub(monthRate2, otherMonthRate2));
			outSatisContrastAnalysisRecord2.setRange(BigDecimalUtil.divide(monthRate2, otherMonthRate2));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord2);

			// 您认为医院公布的当天门诊医生个人信息、出诊信息准确吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord3 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord3.setDesc("您认为医院公布的当天门诊医生个人信息、出诊信息准确吗？");

			double monthRate3 = NumUtil.add(feelOdStatistics.getSph08_verysatisfiedLv(),
					feelOdStatistics.getSph08_satisfiedLv(), feelOdStatistics.getSph08_generalLv());

			double otherMonthRate3 = NumUtil.add(otherFeelOdStatistics.getSph08_verysatisfiedLv(),
					otherFeelOdStatistics.getSph08_satisfiedLv(), otherFeelOdStatistics.getSph08_generalLv());

			outSatisContrastAnalysisRecord3.setMonthRate(monthRate3);
			outSatisContrastAnalysisRecord3.setOthrtRate(otherMonthRate3);
			outSatisContrastAnalysisRecord3.setFluctuate(BigDecimalUtil.sub(monthRate3, otherMonthRate3));
			outSatisContrastAnalysisRecord3.setRange(BigDecimalUtil.divide(monthRate3, otherMonthRate3));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord3);

			// 您对就诊等候区秩序满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord4 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord4.setDesc("您对就诊等候区秩序满意吗？");

			double monthRate4 = NumUtil.add(feelOdStatistics.getSph12_verysatisfiedLv(),
					feelOdStatistics.getSph12_satisfiedLv(), feelOdStatistics.getSph12_generalLv());

			double otherMonthRate4 = NumUtil.add(otherFeelOdStatistics.getSph12_verysatisfiedLv(),
					otherFeelOdStatistics.getSph12_satisfiedLv(), otherFeelOdStatistics.getSph12_generalLv());

			outSatisContrastAnalysisRecord4.setMonthRate(monthRate4);
			outSatisContrastAnalysisRecord4.setOthrtRate(otherMonthRate4);
			outSatisContrastAnalysisRecord4.setFluctuate(BigDecimalUtil.sub(monthRate4, otherMonthRate4));
			outSatisContrastAnalysisRecord4.setRange(BigDecimalUtil.divide(monthRate4, otherMonthRate4));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord4);

			// 您对医生询问病情和检查的耐心细致程度满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord5 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord5.setDesc("您对医生询问病情和检查的耐心细致程度满意吗？");
			double monthRate5 = NumUtil.add(feelOdStatistics.getSph15_verysatisfiedLv(),
					feelOdStatistics.getSph15_satisfiedLv(), feelOdStatistics.getSph15_generalLv());
			double otherMonthRate5 = NumUtil.add(otherFeelOdStatistics.getSph15_verysatisfiedLv(),
					otherFeelOdStatistics.getSph15_satisfiedLv(), otherFeelOdStatistics.getSph15_generalLv());
			outSatisContrastAnalysisRecord5.setMonthRate(monthRate5);
			outSatisContrastAnalysisRecord5.setOthrtRate(otherMonthRate5);
			outSatisContrastAnalysisRecord5.setFluctuate(BigDecimalUtil.sub(monthRate5, otherMonthRate5));
			outSatisContrastAnalysisRecord5.setRange(BigDecimalUtil.divide(monthRate5, otherMonthRate5));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord5);

			// 您对医生解释告知检查结果、治疗方案及用药计划满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord6 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord6.setDesc("您对医生解释告知检查结果、治疗方案及用药计划满意吗？");
			double monthRate6 = NumUtil.add(feelOdStatistics.getSph16_verysatisfiedLv(),
					feelOdStatistics.getSph16_satisfiedLv(), feelOdStatistics.getSph16_generalLv());
			double otherMonthRate6 = NumUtil.add(otherFeelOdStatistics.getSph16_verysatisfiedLv(),
					otherFeelOdStatistics.getSph16_satisfiedLv(), otherFeelOdStatistics.getSph16_generalLv());
			outSatisContrastAnalysisRecord6.setMonthRate(monthRate6);
			outSatisContrastAnalysisRecord6.setOthrtRate(otherMonthRate6);
			outSatisContrastAnalysisRecord6.setFluctuate(BigDecimalUtil.sub(monthRate6, otherMonthRate6));
			outSatisContrastAnalysisRecord6.setRange(BigDecimalUtil.divide(monthRate6, otherMonthRate6));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord6);

			// 在门诊诊断或治疗时，您对医务人员关注并保护您的隐私满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord7 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord7.setDesc("在门诊诊断或治疗时，您对医务人员关注并保护您的隐私满意吗？");
			double monthRate7 = NumUtil.add(feelOdStatistics.getSph17_verysatisfiedLv(),
					feelOdStatistics.getSph17_satisfiedLv(), feelOdStatistics.getSph17_generalLv());
			double otherMonthRate7 = NumUtil.add(otherFeelOdStatistics.getSph17_verysatisfiedLv(),
					otherFeelOdStatistics.getSph17_satisfiedLv(), otherFeelOdStatistics.getSph17_generalLv());
			outSatisContrastAnalysisRecord7.setMonthRate(monthRate7);
			outSatisContrastAnalysisRecord7.setOthrtRate(otherMonthRate7);
			outSatisContrastAnalysisRecord7.setFluctuate(BigDecimalUtil.sub(monthRate7, otherMonthRate7));
			outSatisContrastAnalysisRecord7.setRange(BigDecimalUtil.divide(monthRate7, otherMonthRate7));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord7);

			// 您对门诊检验科检查等候时间满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord8 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord8.setDesc("您对门诊检验科检查等候时间满意吗？");
			double monthRate8 = NumUtil.add(feelOdStatistics.getSph18_verysatisfiedLv(),
					feelOdStatistics.getSph18_satisfiedLv(), feelOdStatistics.getSph18_generalLv());
			double otherMonthRate8 = NumUtil.add(otherFeelOdStatistics.getSph18_verysatisfiedLv(),
					otherFeelOdStatistics.getSph18_satisfiedLv(), otherFeelOdStatistics.getSph18_generalLv());
			outSatisContrastAnalysisRecord8.setMonthRate(monthRate8);
			outSatisContrastAnalysisRecord8.setOthrtRate(otherMonthRate8);
			outSatisContrastAnalysisRecord8.setFluctuate(BigDecimalUtil.sub(monthRate8, otherMonthRate8));
			outSatisContrastAnalysisRecord8.setRange(BigDecimalUtil.divide(monthRate8, otherMonthRate8));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord8);

			// 您对门诊放射X光检查等候时间满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord9 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord9.setDesc("您对门诊放射X光检查等候时间满意吗？");
			double monthRate9 = NumUtil.add(feelOdStatistics.getSph20_verysatisfiedLv(),
					feelOdStatistics.getSph20_satisfiedLv(), feelOdStatistics.getSph20_generalLv());
			double otherMonthRate9 = NumUtil.add(otherFeelOdStatistics.getSph20_verysatisfiedLv(),
					otherFeelOdStatistics.getSph20_satisfiedLv(), otherFeelOdStatistics.getSph20_generalLv());
			outSatisContrastAnalysisRecord9.setMonthRate(monthRate9);
			outSatisContrastAnalysisRecord9.setOthrtRate(otherMonthRate9);
			outSatisContrastAnalysisRecord9.setFluctuate(BigDecimalUtil.sub(monthRate9, otherMonthRate9));
			outSatisContrastAnalysisRecord9.setRange(BigDecimalUtil.divide(monthRate9, otherMonthRate9));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord9);

			// 您对放射X光检查出报告时间满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord10 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord10.setDesc("您对放射X光检查出报告时间满意吗？");
			double monthRate10 = NumUtil.add(feelOdStatistics.getSph21_verysatisfiedLv(),
					feelOdStatistics.getSph21_satisfiedLv(), feelOdStatistics.getSph21_generalLv());
			double otherMonthRate10 = NumUtil.add(otherFeelOdStatistics.getSph21_verysatisfiedLv(),
					otherFeelOdStatistics.getSph21_satisfiedLv(), otherFeelOdStatistics.getSph21_generalLv());
			outSatisContrastAnalysisRecord10.setMonthRate(monthRate10);
			outSatisContrastAnalysisRecord10.setOthrtRate(otherMonthRate10);
			outSatisContrastAnalysisRecord10.setFluctuate(BigDecimalUtil.sub(monthRate10, otherMonthRate10));
			outSatisContrastAnalysisRecord10.setRange(BigDecimalUtil.divide(monthRate10, otherMonthRate10));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord10);

			// 您对门诊CT检查等候时间满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord11 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord11.setDesc("您对门诊CT检查等候时间满意吗？");
			double monthRate11 = NumUtil.add(feelOdStatistics.getSph23_verysatisfiedLv(),
					feelOdStatistics.getSph23_satisfiedLv(), feelOdStatistics.getSph23_generalLv());
			double otherMonthRate11 = NumUtil.add(otherFeelOdStatistics.getSph23_verysatisfiedLv(),
					otherFeelOdStatistics.getSph23_satisfiedLv(), otherFeelOdStatistics.getSph23_generalLv());
			outSatisContrastAnalysisRecord11.setMonthRate(monthRate11);
			outSatisContrastAnalysisRecord11.setOthrtRate(otherMonthRate11);
			outSatisContrastAnalysisRecord11.setFluctuate(BigDecimalUtil.sub(monthRate11, otherMonthRate11));
			outSatisContrastAnalysisRecord11.setRange(BigDecimalUtil.divide(monthRate11, otherMonthRate11));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord11);

			// 您对CT检查出报告时间满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord12 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord12.setDesc("您对CT检查出报告时间满意吗？");
			double monthRate12 = NumUtil.add(feelOdStatistics.getSph24_verysatisfiedLv(),
					feelOdStatistics.getSph24_satisfiedLv(), feelOdStatistics.getSph24_generalLv());
			double otherMonthRate12 = NumUtil.add(otherFeelOdStatistics.getSph24_verysatisfiedLv(),
					otherFeelOdStatistics.getSph24_satisfiedLv(), otherFeelOdStatistics.getSph24_generalLv());
			outSatisContrastAnalysisRecord12.setMonthRate(monthRate12);
			outSatisContrastAnalysisRecord12.setOthrtRate(otherMonthRate12);
			outSatisContrastAnalysisRecord12.setFluctuate(BigDecimalUtil.sub(monthRate12, otherMonthRate12));
			outSatisContrastAnalysisRecord12.setRange(BigDecimalUtil.divide(monthRate12, otherMonthRate12));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord12);

			// 您对门诊放射MRI检查等候时间满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord13 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord13.setDesc("您对门诊放射MRI检查等候时间满意吗？");
			double monthRate13 = NumUtil.add(feelOdStatistics.getSph26_verysatisfiedLv(),
					feelOdStatistics.getSph26_satisfiedLv(), feelOdStatistics.getSph26_generalLv());
			double otherMonthRate13 = NumUtil.add(otherFeelOdStatistics.getSph26_verysatisfiedLv(),
					otherFeelOdStatistics.getSph26_satisfiedLv(), otherFeelOdStatistics.getSph26_generalLv());
			outSatisContrastAnalysisRecord13.setMonthRate(monthRate13);
			outSatisContrastAnalysisRecord13.setOthrtRate(otherMonthRate13);
			outSatisContrastAnalysisRecord13.setFluctuate(BigDecimalUtil.sub(monthRate13, otherMonthRate13));
			outSatisContrastAnalysisRecord13.setRange(BigDecimalUtil.divide(monthRate13, otherMonthRate13));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord13);

			// 您对放射MRI检查出报告时间满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord14 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord14.setDesc("您对放射MRI检查出报告时间满意吗？");
			double monthRate14 = NumUtil.add(feelOdStatistics.getSph27_verysatisfiedLv(),
					feelOdStatistics.getSph27_satisfiedLv(), feelOdStatistics.getSph27_generalLv());
			double otherMonthRate14 = NumUtil.add(otherFeelOdStatistics.getSph27_verysatisfiedLv(),
					otherFeelOdStatistics.getSph27_satisfiedLv(), otherFeelOdStatistics.getSph27_generalLv());
			outSatisContrastAnalysisRecord14.setMonthRate(monthRate14);
			outSatisContrastAnalysisRecord14.setOthrtRate(otherMonthRate14);
			outSatisContrastAnalysisRecord14.setFluctuate(BigDecimalUtil.sub(monthRate14, otherMonthRate14));
			outSatisContrastAnalysisRecord14.setRange(BigDecimalUtil.divide(monthRate14, otherMonthRate14));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord14);

			// 您对门诊超声科检查等候时间满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord15 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord15.setDesc("您对门诊超声科检查等候时间满意吗？");
			double monthRate15 = NumUtil.add(feelOdStatistics.getSph29_verysatisfiedLv(),
					feelOdStatistics.getSph29_satisfiedLv(), feelOdStatistics.getSph29_generalLv());
			double otherMonthRate15 = NumUtil.add(otherFeelOdStatistics.getSph29_verysatisfiedLv(),
					otherFeelOdStatistics.getSph29_satisfiedLv(), otherFeelOdStatistics.getSph29_generalLv());
			outSatisContrastAnalysisRecord15.setMonthRate(monthRate15);
			outSatisContrastAnalysisRecord15.setOthrtRate(otherMonthRate15);
			outSatisContrastAnalysisRecord15.setFluctuate(BigDecimalUtil.sub(monthRate15, otherMonthRate15));
			outSatisContrastAnalysisRecord15.setRange(BigDecimalUtil.divide(monthRate15, otherMonthRate15));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord15);

			// 您对超声科检查出报告时间满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord16 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord16.setDesc("您对超声科检查出报告时间满意吗？");
			double monthRate16 = NumUtil.add(feelOdStatistics.getSph30_verysatisfiedLv(),
					feelOdStatistics.getSph30_satisfiedLv(), feelOdStatistics.getSph30_generalLv());
			double otherMonthRate16 = NumUtil.add(otherFeelOdStatistics.getSph30_verysatisfiedLv(),
					otherFeelOdStatistics.getSph30_satisfiedLv(), otherFeelOdStatistics.getSph30_generalLv());
			outSatisContrastAnalysisRecord16.setMonthRate(monthRate16);
			outSatisContrastAnalysisRecord16.setOthrtRate(otherMonthRate16);
			outSatisContrastAnalysisRecord16.setFluctuate(BigDecimalUtil.sub(monthRate16, otherMonthRate16));
			outSatisContrastAnalysisRecord16.setRange(BigDecimalUtil.divide(monthRate16, otherMonthRate16));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord16);

			// 您对医护人员的咨询服务满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord17 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord17.setDesc("您对医护人员的咨询服务满意吗？");
			double monthRate17 = NumUtil.add(feelOdStatistics.getSph31_verysatisfiedLv(),
					feelOdStatistics.getSph31_satisfiedLv(), feelOdStatistics.getSph31_generalLv());
			double otherMonthRate17 = NumUtil.add(otherFeelOdStatistics.getSph31_verysatisfiedLv(),
					otherFeelOdStatistics.getSph31_satisfiedLv(), otherFeelOdStatistics.getSph31_generalLv());
			outSatisContrastAnalysisRecord17.setMonthRate(monthRate17);
			outSatisContrastAnalysisRecord17.setOthrtRate(otherMonthRate17);
			outSatisContrastAnalysisRecord17.setFluctuate(BigDecimalUtil.sub(monthRate17, otherMonthRate17));
			outSatisContrastAnalysisRecord17.setRange(BigDecimalUtil.divide(monthRate17, otherMonthRate17));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord17);

			// 您对门诊提供的健康宣教服务满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord18 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord18.setDesc("您对门诊提供的健康宣教服务满意吗？");
			double monthRate18 = NumUtil.add(feelOdStatistics.getSph32_verysatisfiedLv(),
					feelOdStatistics.getSph32_satisfiedLv(), feelOdStatistics.getSph32_generalLv());
			double otherMonthRate18 = NumUtil.add(otherFeelOdStatistics.getSph32_verysatisfiedLv(),
					otherFeelOdStatistics.getSph32_satisfiedLv(), otherFeelOdStatistics.getSph32_generalLv());
			outSatisContrastAnalysisRecord18.setMonthRate(monthRate18);
			outSatisContrastAnalysisRecord18.setOthrtRate(otherMonthRate18);
			outSatisContrastAnalysisRecord18.setFluctuate(BigDecimalUtil.sub(monthRate18, otherMonthRate18));
			outSatisContrastAnalysisRecord18.setRange(BigDecimalUtil.divide(monthRate18, otherMonthRate18));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord18);

			// 您对门诊提供的轮椅服务满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord19 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord19.setDesc("您对门诊提供的轮椅服务满意吗？");
			double monthRate19 = NumUtil.add(feelOdStatistics.getSph37_verysatisfiedLv(),
					feelOdStatistics.getSph37_satisfiedLv(), feelOdStatistics.getSph37_generalLv());
			double otherMonthRate19 = NumUtil.add(otherFeelOdStatistics.getSph37_verysatisfiedLv(),
					otherFeelOdStatistics.getSph37_satisfiedLv(), otherFeelOdStatistics.getSph37_generalLv());
			outSatisContrastAnalysisRecord19.setMonthRate(monthRate19);
			outSatisContrastAnalysisRecord19.setOthrtRate(otherMonthRate19);
			outSatisContrastAnalysisRecord19.setFluctuate(BigDecimalUtil.sub(monthRate19, otherMonthRate19));
			outSatisContrastAnalysisRecord19.setRange(BigDecimalUtil.divide(monthRate19, otherMonthRate19));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord19);

			// 您对门诊提供的轮椅服务满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord20 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord20.setDesc("您对门诊提供的轮椅服务满意吗？");
			double monthRate20 = NumUtil.add(feelOdStatistics.getSph34_verysatisfiedLv(),
					feelOdStatistics.getSph34_satisfiedLv(), feelOdStatistics.getSph34_generalLv());
			double otherMonthRate20 = NumUtil.add(otherFeelOdStatistics.getSph34_verysatisfiedLv(),
					otherFeelOdStatistics.getSph34_satisfiedLv(), otherFeelOdStatistics.getSph34_generalLv());
			outSatisContrastAnalysisRecord20.setMonthRate(monthRate20);
			outSatisContrastAnalysisRecord20.setOthrtRate(otherMonthRate20);
			outSatisContrastAnalysisRecord20.setFluctuate(BigDecimalUtil.sub(monthRate20, otherMonthRate20));
			outSatisContrastAnalysisRecord20.setRange(BigDecimalUtil.divide(monthRate20, otherMonthRate20));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord20);

			// 您对门诊环境卫生状况满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord21 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord21.setDesc("您对门诊环境卫生状况满意吗？");
			double monthRate21 = NumUtil.add(feelOdStatistics.getSph35_verysatisfiedLv(),
					feelOdStatistics.getSph35_satisfiedLv(), feelOdStatistics.getSph35_generalLv());
			double otherMonthRate21 = NumUtil.add(otherFeelOdStatistics.getSph35_verysatisfiedLv(),
					otherFeelOdStatistics.getSph35_satisfiedLv(), otherFeelOdStatistics.getSph35_generalLv());
			outSatisContrastAnalysisRecord21.setMonthRate(monthRate21);
			outSatisContrastAnalysisRecord21.setOthrtRate(otherMonthRate21);
			outSatisContrastAnalysisRecord21.setFluctuate(BigDecimalUtil.sub(monthRate21, otherMonthRate21));
			outSatisContrastAnalysisRecord21.setRange(BigDecimalUtil.divide(monthRate21, otherMonthRate21));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord21);

			// 您对医院的安全保卫措施满意吗？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord22 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord22.setDesc("您对医院的安全保卫措施满意吗？");
			double monthRate22 = NumUtil.add(feelOdStatistics.getSph36_verysatisfiedLv(),
					feelOdStatistics.getSph36_satisfiedLv(), feelOdStatistics.getSph36_generalLv());
			double otherMonthRate22 = NumUtil.add(otherFeelOdStatistics.getSph36_verysatisfiedLv(),
					otherFeelOdStatistics.getSph36_satisfiedLv(), otherFeelOdStatistics.getSph36_generalLv());
			outSatisContrastAnalysisRecord22.setMonthRate(monthRate22);
			outSatisContrastAnalysisRecord22.setOthrtRate(otherMonthRate22);
			outSatisContrastAnalysisRecord22.setFluctuate(BigDecimalUtil.sub(monthRate22, otherMonthRate22));
			outSatisContrastAnalysisRecord22.setRange(BigDecimalUtil.divide(monthRate22, otherMonthRate22));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord22);

			// 您等候取药大约用了多长时间？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord23 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord23.setDesc("您等候取药大约用了多长时间？");
			double monthRate23 = NumUtil.add(feelOdStatistics.getSph33_verysatisfiedLv(),
					feelOdStatistics.getSph33_satisfiedLv(), feelOdStatistics.getSph33_generalLv());
			double otherMonthRate23 = NumUtil.add(otherFeelOdStatistics.getSph33_verysatisfiedLv(),
					otherFeelOdStatistics.getSph33_satisfiedLv(), otherFeelOdStatistics.getSph33_generalLv());
			outSatisContrastAnalysisRecord23.setMonthRate(monthRate23);
			outSatisContrastAnalysisRecord23.setOthrtRate(otherMonthRate23);
			outSatisContrastAnalysisRecord23.setFluctuate(BigDecimalUtil.sub(monthRate23, otherMonthRate23));
			outSatisContrastAnalysisRecord23.setRange(BigDecimalUtil.divide(monthRate23, otherMonthRate23));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord23);

			// 从护士开始分诊，您等候分诊取号用了多长时间？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord24 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord24.setDesc("从护士开始分诊，您等候分诊取号用了多长时间？");
			double monthRate24 = NumUtil.add(feelOdStatistics.getSph09_verysatisfiedLv(),
					feelOdStatistics.getSph09_satisfiedLv(), feelOdStatistics.getSph09_generalLv());
			double otherMonthRate24 = NumUtil.add(otherFeelOdStatistics.getSph09_verysatisfiedLv(),
					otherFeelOdStatistics.getSph09_satisfiedLv(), otherFeelOdStatistics.getSph09_generalLv());
			outSatisContrastAnalysisRecord24.setMonthRate(monthRate24);
			outSatisContrastAnalysisRecord24.setOthrtRate(otherMonthRate24);
			outSatisContrastAnalysisRecord24.setFluctuate(BigDecimalUtil.sub(monthRate24, otherMonthRate24));
			outSatisContrastAnalysisRecord24.setRange(BigDecimalUtil.divide(monthRate24, otherMonthRate24));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord24);

			// 您在缴费窗口缴费等候了多长时间？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord25 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord25.setDesc("您在缴费窗口缴费等候了多长时间？");
			double monthRate25 = NumUtil.add(feelOdStatistics.getSph10_verysatisfiedLv(),
					feelOdStatistics.getSph10_satisfiedLv(), feelOdStatistics.getSph10_generalLv());
			double otherMonthRate25 = NumUtil.add(otherFeelOdStatistics.getSph10_verysatisfiedLv(),
					otherFeelOdStatistics.getSph10_satisfiedLv(), otherFeelOdStatistics.getSph10_generalLv());
			outSatisContrastAnalysisRecord25.setMonthRate(monthRate25);
			outSatisContrastAnalysisRecord25.setOthrtRate(otherMonthRate25);
			outSatisContrastAnalysisRecord25.setFluctuate(BigDecimalUtil.sub(monthRate25, otherMonthRate25));
			outSatisContrastAnalysisRecord25.setRange(BigDecimalUtil.divide(monthRate25, otherMonthRate25));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord25);

			// 从您的就诊小票上的候诊时间到医生呼叫到您的名字大约用了多长时间？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord26 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord26.setDesc("从您的就诊小票上的候诊时间到医生呼叫到您的名字大约用了多长时间？");
			double monthRate26 = NumUtil.add(feelOdStatistics.getSph13_verysatisfiedLv(),
					feelOdStatistics.getSph13_satisfiedLv(), feelOdStatistics.getSph13_generalLv());
			double otherMonthRate26 = NumUtil.add(otherFeelOdStatistics.getSph13_verysatisfiedLv(),
					otherFeelOdStatistics.getSph13_satisfiedLv(), otherFeelOdStatistics.getSph13_generalLv());
			outSatisContrastAnalysisRecord26.setMonthRate(monthRate26);
			outSatisContrastAnalysisRecord26.setOthrtRate(otherMonthRate26);
			outSatisContrastAnalysisRecord26.setFluctuate(BigDecimalUtil.sub(monthRate26, otherMonthRate26));
			outSatisContrastAnalysisRecord26.setRange(BigDecimalUtil.divide(monthRate26, otherMonthRate26));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord26);

			// 门诊医生为您看病大约用了多长时间？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord27 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord27.setDesc("门诊医生为您看病大约用了多长时间？");
			double monthRate27 = NumUtil.add(feelOdStatistics.getSph14_verysatisfiedLv(),
					feelOdStatistics.getSph14_satisfiedLv(), feelOdStatistics.getSph14_generalLv());
			double otherMonthRate27 = NumUtil.add(otherFeelOdStatistics.getSph14_verysatisfiedLv(),
					otherFeelOdStatistics.getSph14_satisfiedLv(), otherFeelOdStatistics.getSph14_generalLv());
			outSatisContrastAnalysisRecord27.setMonthRate(monthRate27);
			outSatisContrastAnalysisRecord27.setOthrtRate(otherMonthRate27);
			outSatisContrastAnalysisRecord27.setFluctuate(BigDecimalUtil.sub(monthRate27, otherMonthRate27));
			outSatisContrastAnalysisRecord27.setRange(BigDecimalUtil.divide(monthRate27, otherMonthRate27));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord27);

			// 结合病情，您对此次就诊的费用接受程度是怎样的？
			OutSatisContrastAnalysisRecord outSatisContrastAnalysisRecord28 = new OutSatisContrastAnalysisRecord();
			outSatisContrastAnalysisRecord28.setDesc("结合病情，您对此次就诊的费用接受程度是怎样的？");
			double monthRate28 = NumUtil.add(feelOdStatistics.getSph38_verysatisfiedLv(),
					feelOdStatistics.getSph38_satisfiedLv(), feelOdStatistics.getSph38_generalLv());
			double otherMonthRate28 = NumUtil.add(otherFeelOdStatistics.getSph38_verysatisfiedLv(),
					otherFeelOdStatistics.getSph38_satisfiedLv(), otherFeelOdStatistics.getSph38_generalLv());
			outSatisContrastAnalysisRecord28.setMonthRate(monthRate28);
			outSatisContrastAnalysisRecord28.setOthrtRate(otherMonthRate28);
			outSatisContrastAnalysisRecord28.setFluctuate(BigDecimalUtil.sub(monthRate28, otherMonthRate28));
			outSatisContrastAnalysisRecord28.setRange(BigDecimalUtil.divide(monthRate28, otherMonthRate28));
			sortOutSatisContrastAnalysisRecords.add(outSatisContrastAnalysisRecord28);

			Collections.sort(sortOutSatisContrastAnalysisRecords, new Comparator<OutSatisContrastAnalysisRecord>() {

				@Override
				public int compare(OutSatisContrastAnalysisRecord o1, OutSatisContrastAnalysisRecord o2) {

					return Double.compare(o2.getMonthRate(), o1.getMonthRate());

				}
			});

			outSatisContrastAnalysisRecords.addAll(sortOutSatisContrastAnalysisRecords);

			outSatisContrastAnalysisInfo.setOutSatisContrastAnalysisRecord(outSatisContrastAnalysisRecords);

		} catch (ParseException e) {
			e.printStackTrace();
		}

		return outSatisContrastAnalysisInfo;
	}

	@Transactional(readOnly = true)
	@Override
	public void addParameterSetting(StatisticalReportParam statisticalReportParam) {
		Long id = statisticalReportParam.getId();
		if (id == null) {
			statisticalReportParamMapper.insertSelective(statisticalReportParam);
		} else {
			statisticalReportParamMapper.updateByPrimaryKey(statisticalReportParam);
		}

	}

	@Override
	public PageInfo<StatisticalReportParam> getStatisticalReportParamPageInfo(PageParam pageParam) {
		PageHelper.startPage(pageParam.getPage(), pageParam.getLimit());
		List<StatisticalReportParam> statisticalReportParamList = statisticalReportParamMapper
				.getAllStatisticalReportParam();
		// 用PageInfo对结果进行包装
		PageInfo<StatisticalReportParam> page = new PageInfo<StatisticalReportParam>(statisticalReportParamList);
		return page;
	}

	@Override
	public StatisticalReportParam getParameterSettingById(Integer id) {
		return statisticalReportParamMapper.selectByPrimaryKey(new BigDecimal(id));
	}

	@Transactional(readOnly = true)
	@Override
	public QcBackInfo getQcBackInfo(StatisticalReportParam statisticalReportParam, String orgCode) {

		QcBackInfo qcBackInfo = new QcBackInfo();

		String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());

		String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
		String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());

		String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
		String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());

		QcDeath qcData = this.getQcDeath(startTime1, endTime1, orgCode);

		QcDeath preMonthQcData = this.getQcDeath(startTime2, endTime2, orgCode);

		QcDeath lastYearMonthQcData = this.getQcDeath(startTime3, endTime3, orgCode);

		QcBackRecord qcBackRecord1 = new QcBackRecord();
		qcBackRecord1.setItem("住院患者出院后非预期再住院患者人数");

		QcBackRecord qcBackRecord2 = new QcBackRecord();
		qcBackRecord2.setItem("出院当天非预期再住院患者人数");

		QcBackRecord qcBackRecord3 = new QcBackRecord();
		qcBackRecord3.setItem("出院2-7天内再住院人数");

		QcBackRecord qcBackRecord4 = new QcBackRecord();
		qcBackRecord4.setItem("出院8-14天内再住院人数");

		QcBackRecord qcBackRecord5 = new QcBackRecord();
		qcBackRecord5.setItem("出院15-31天内再住院人数");

		QcBackRecord qcBackRecord6 = new QcBackRecord();
		qcBackRecord6.setItem("手术患者非计划重返手术室再次手术人数");

		QcBackRecord qcBackRecord7 = new QcBackRecord();
		qcBackRecord7.setItem("术后48小时（2天）以内非计划重返手术室再次手术人数");

		QcBackRecord qcBackRecord8 = new QcBackRecord();
		qcBackRecord8.setItem("术后3-31天非计划重返手术室再次手术人数");

		if (qcData != null) {
			int zrs = qcData.getZrs();

			int ssjczrs = qcData.getSsjczrs();

			// 住院患者出院后非预期再住院患者人数
			int ssytnzzyrs = qcData.getSsytnzzyrs();
			BigDecimal ssytnzzyrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(ssytnzzyrs), new BigDecimal(zrs));
			qcBackRecord1.setNum(ssytnzzyrs);
			qcBackRecord1.setRate(ssytnzzyrsRate);

			// 当天再住院
			int dtzzyrs = qcData.getDtzzyrs();

			BigDecimal dtzzyrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(dtzzyrs), new BigDecimal(zrs));
			qcBackRecord2.setNum(dtzzyrs);
			qcBackRecord2.setRate(dtzzyrsRate);

			// 出院2-7天内再住院人数
			int zzy2_7 = qcData.getZzy2_7();
			BigDecimal zzy2_7Rate = BigDecimalUtil.getDivideRate(new BigDecimal(zzy2_7), new BigDecimal(zrs));
			qcBackRecord3.setNum(zzy2_7);
			qcBackRecord3.setRate(zzy2_7Rate);

			// 出院8-14天内再住院人数

			int zzy8_14 = qcData.getZzy8_14();
			BigDecimal zzy8_14Rate = BigDecimalUtil.getDivideRate(new BigDecimal(zzy8_14), new BigDecimal(zrs));
			qcBackRecord4.setNum(zzy8_14);
			qcBackRecord4.setRate(zzy8_14Rate);

			// 出院15-31天内再住院人数
			int zzy15_31 = qcData.getZzy15_31();
			BigDecimal zzy15_31Rate = BigDecimalUtil.getDivideRate(new BigDecimal(zzy15_31), new BigDecimal(zrs));
			qcBackRecord5.setNum(zzy15_31);
			qcBackRecord5.setRate(zzy15_31Rate);

			// 手术患者非计划重返手术室再次手术人数
			int sanshineizssrs = qcData.getSanshineizssrs();
			BigDecimal sanshineizssrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(sanshineizssrs),
					new BigDecimal(ssjczrs));
			qcBackRecord6.setNum(sanshineizssrs);
			qcBackRecord6.setRate(sanshineizssrsRate);

			// 术后48小时（2天）以内非计划重返手术室再次手术人数
			int erzssrs = qcData.getErzssrs();
			BigDecimal erzssrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(erzssrs), new BigDecimal(ssjczrs));
			qcBackRecord7.setNum(erzssrs);
			qcBackRecord7.setRate(erzssrsRate);

			// 术后3-31天非计划重返手术室再次手术人数

			int sanshizssrs = qcData.getSanshizssrs();
			BigDecimal sanshizssrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(sanshizssrs),
					new BigDecimal(ssjczrs));
			qcBackRecord8.setNum(sanshizssrs);
			qcBackRecord8.setRate(sanshizssrsRate);

			StringBuilder textBuilder = new StringBuilder();
			textBuilder.append("    " + statisticalReportParam.getStatics1Name()).append("住院患者出院后31天内非预期再住院患者人数为")
					.append(ssytnzzyrs).append("人，占出院人数的").append(ssytnzzyrsRate).append("%；其中出院当天再住院患者人数为")
					.append(dtzzyrs).append("人（占出院人数的").append(dtzzyrsRate).append("%）；出院2-7天非预期再住院患者人数为")
					.append(zzy2_7).append("人（占出院人数的").append(zzy2_7Rate).append("%）；出院8-14天非预期再住院患者人数为")
					.append(zzy8_14).append("人（占出院人数的").append(zzy8_14Rate).append("%）；出院15-31天非预期再住院患者人数为")
					.append(zzy15_31).append("人（占出院人数的").append(zzy15_31Rate).append("%）。\n")
					.append("    " + statisticalReportParam.getStatics1Name()).append("手术患者非计划重返手术室再次手术人数为")
					.append(sanshineizssrs).append("人，占手术及治疗性操作人数的").append(sanshineizssrsRate)
					.append("%。其中，术后48小时以内非计划重返手术室再次手术人数为").append(erzssrs).append("人，占手术及治疗性操作人数的").append(erzssrsRate)
					.append("%；术后3-31天非计划重返手术室再次手术人数为").append(sanshizssrs).append("人，占手术及治疗性操作人数的")
					.append(sanshizssrsRate).append("%。");

			qcBackInfo.setText(textBuilder.toString());
		}

		if (preMonthQcData != null) {
			int zrs = preMonthQcData.getZrs();

			int ssjczrs = preMonthQcData.getSsjczrs();

			// 住院患者出院后非预期再住院患者人数
			int ssytnzzyrs = preMonthQcData.getSsytnzzyrs();
			BigDecimal ssytnzzyrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(ssytnzzyrs), new BigDecimal(zrs));
			qcBackRecord1.setPreMonthNum(ssytnzzyrs);
			qcBackRecord1.setPreMonthRate(ssytnzzyrsRate);

			// 当天再住院
			int dtzzyrs = preMonthQcData.getDtzzyrs();

			BigDecimal dtzzyrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(dtzzyrs), new BigDecimal(zrs));
			qcBackRecord2.setPreMonthNum(preMonthQcData.getDtzzyrs());
			qcBackRecord2.setPreMonthRate(dtzzyrsRate);

			// 出院2-7天内再住院人数
			int zzy2_7 = preMonthQcData.getZzy2_7();
			BigDecimal zzy2_7Rate = BigDecimalUtil.getDivideRate(new BigDecimal(zzy2_7), new BigDecimal(zrs));
			qcBackRecord3.setPreMonthNum(zzy2_7);
			qcBackRecord3.setPreMonthRate(zzy2_7Rate);

			// 出院8-14天内再住院人数

			int zzy8_14 = preMonthQcData.getZzy8_14();
			BigDecimal zzy8_14Rate = BigDecimalUtil.getDivideRate(new BigDecimal(zzy8_14), new BigDecimal(zrs));
			qcBackRecord4.setPreMonthNum(zzy8_14);
			qcBackRecord4.setPreMonthRate(zzy8_14Rate);

			// 出院15-31天内再住院人数
			int zzy15_31 = preMonthQcData.getZzy15_31();
			BigDecimal zzy15_31Rate = BigDecimalUtil.getDivideRate(new BigDecimal(zzy15_31), new BigDecimal(zrs));
			qcBackRecord5.setPreMonthNum(zzy15_31);
			qcBackRecord5.setPreMonthRate(zzy15_31Rate);

			// 手术患者非计划重返手术室再次手术人数
			int sanshineizssrs = preMonthQcData.getSanshineizssrs();
			BigDecimal sanshineizssrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(sanshineizssrs),
					new BigDecimal(ssjczrs));
			qcBackRecord6.setPreMonthNum(sanshineizssrs);
			qcBackRecord6.setPreMonthRate(sanshineizssrsRate);

			// 术后48小时（2天）以内非计划重返手术室再次手术人数
			int erzssrs = preMonthQcData.getErzssrs();
			BigDecimal erzssrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(erzssrs), new BigDecimal(ssjczrs));
			qcBackRecord7.setPreMonthNum(erzssrs);
			qcBackRecord7.setPreMonthRate(erzssrsRate);

			// 术后3-31天非计划重返手术室再次手术人数

			int sanshizssrs = preMonthQcData.getSanshizssrs();
			BigDecimal sanshizssrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(sanshizssrs),
					new BigDecimal(ssjczrs));
			qcBackRecord8.setPreMonthNum(sanshizssrs);
			qcBackRecord8.setPreMonthRate(sanshizssrsRate);
		}

		if (lastYearMonthQcData != null) {
			int zrs = lastYearMonthQcData.getZrs();

			int ssjczrs = lastYearMonthQcData.getSsjczrs();

			// 住院患者出院后非预期再住院患者人数
			int ssytnzzyrs = lastYearMonthQcData.getSsytnzzyrs();
			BigDecimal ssytnzzyrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(ssytnzzyrs), new BigDecimal(zrs));
			qcBackRecord1.setLastYearMonthNum(ssytnzzyrs);
			qcBackRecord1.setLastYearMonthRate(ssytnzzyrsRate);

			// 当天再住院
			int dtzzyrs = lastYearMonthQcData.getDtzzyrs();

			BigDecimal dtzzyrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(dtzzyrs), new BigDecimal(zrs));
			qcBackRecord2.setLastYearMonthNum(qcData.getDtzzyrs());
			qcBackRecord2.setLastYearMonthRate(dtzzyrsRate);

			// 出院2-7天内再住院人数
			int zzy2_7 = lastYearMonthQcData.getZzy2_7();
			BigDecimal zzy2_7Rate = BigDecimalUtil.getDivideRate(new BigDecimal(zzy2_7), new BigDecimal(zrs));
			qcBackRecord3.setLastYearMonthNum(zzy2_7);
			qcBackRecord3.setLastYearMonthRate(zzy2_7Rate);

			// 出院8-14天内再住院人数

			int zzy8_14 = lastYearMonthQcData.getZzy8_14();
			BigDecimal zzy8_14Rate = BigDecimalUtil.getDivideRate(new BigDecimal(zzy8_14), new BigDecimal(zrs));
			qcBackRecord4.setLastYearMonthNum(zzy8_14);
			qcBackRecord4.setLastYearMonthRate(zzy8_14Rate);

			// 出院15-31天内再住院人数
			int zzy15_31 = lastYearMonthQcData.getZzy15_31();
			BigDecimal zzy15_31Rate = BigDecimalUtil.getDivideRate(new BigDecimal(zzy15_31), new BigDecimal(zrs));
			qcBackRecord5.setLastYearMonthNum(zzy15_31);
			qcBackRecord5.setLastYearMonthRate(zzy15_31Rate);

			// 手术患者非计划重返手术室再次手术人数
			int sanshineizssrs = lastYearMonthQcData.getSanshineizssrs();
			BigDecimal sanshineizssrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(sanshineizssrs),
					new BigDecimal(ssjczrs));
			qcBackRecord6.setLastYearMonthNum(sanshineizssrs);
			qcBackRecord6.setLastYearMonthRate(sanshineizssrsRate);

			// 术后48小时（2天）以内非计划重返手术室再次手术人数
			int erzssrs = lastYearMonthQcData.getErzssrs();
			BigDecimal erzssrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(erzssrs), new BigDecimal(ssjczrs));
			qcBackRecord7.setLastYearMonthNum(erzssrs);
			qcBackRecord7.setLastYearMonthRate(erzssrsRate);

			// 术后3-31天非计划重返手术室再次手术人数

			int sanshizssrs = lastYearMonthQcData.getSanshizssrs();
			BigDecimal sanshizssrsRate = BigDecimalUtil.getDivideRate(new BigDecimal(sanshizssrs),
					new BigDecimal(ssjczrs));
			qcBackRecord8.setLastYearMonthNum(sanshizssrs);
			qcBackRecord8.setLastYearMonthRate(sanshizssrsRate);
		}

		List<QcBackRecord> qcBackRecordList = new LinkedList<QcBackRecord>();
		qcBackRecordList.add(qcBackRecord1);
		qcBackRecordList.add(qcBackRecord2);
		qcBackRecordList.add(qcBackRecord3);
		qcBackRecordList.add(qcBackRecord4);
		qcBackRecordList.add(qcBackRecord5);
		qcBackRecordList.add(qcBackRecord6);
		qcBackRecordList.add(qcBackRecord7);
		qcBackRecordList.add(qcBackRecord8);

		qcBackInfo.setQcBackRecordList(qcBackRecordList);

		return qcBackInfo;

	}

	public QcDeath getQcDeath(String startTime, String endTime, String orgCode) {

		QcDeath qc = new QcDeath();
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);

		BigDecimal totalCout = mrInBasicMapper.getMrInBasicCount(mrInBasicQuery);
		qc.setZrs(totalCout.intValue());

		OperationNumber operationNumber = mrInBasicMapper.getOperationDataInfo(mrInBasicQuery);

		qc.setSsjczrs(operationNumber.getSszlczs().intValue());

		List<BaseForTj> baseForTjList = mrInBasicMapper.getChongfuzhuYuan_zyzd(mrInBasicQuery);

		if (baseForTjList != null && baseForTjList.size() > 0) {
			CytianshuData cyData = CyTianshuDataUtil.getChongfuzhuYuanToMap_new(baseForTjList);
			qc.setDtzzyrs(cyData.getDangtianzzy());
			qc.setSwtzzyrs(cyData.getShiwuzzy());
			qc.setSsytnzzyrs(cyData.getSanshiyizzy());
			qc.setSsytzzyrs(cyData.getErdaosanshiyizzy());
			qc.setZzy2_7(cyData.getZzy2_7());
			qc.setZzy8_14(cyData.getZzy8_14());
			qc.setZzy15_31(cyData.getZzy15_31());
		}

		List<BaseForSS> opsEs = mrInBasicMapper.getSSTime(mrInBasicQuery);

		if (opsEs.size() > 0) {
			CytianshuData ssDate = CyTianshuDataUtil.getSSToMap_new(opsEs);
			qc.setErzssrs(ssDate.getDangtianzzy());
			qc.setSanshizssrs(ssDate.getShiwuzzy());
			qc.setSanshineizssrs(ssDate.getSanshiyizzy());
		}

		return qc;

	}

	@Transactional(readOnly = true)
	@Override
	public QcAcquiredInfo getQcAcquiredInfo(StatisticalReportParam statisticalReportParam, String orgCode) {
		QcAcquiredInfo qcAcquiredInfo = new QcAcquiredInfo();
		List<QcAcquiredRecord> qcAcquiredRecordList = new LinkedList<QcAcquiredRecord>();
		List<QcAcquiredRecord> newQcAcquiredRecordList = new LinkedList<QcAcquiredRecord>();
		//List<TTjBzfl> tTjBzflList = mrInBasicMapper.getTTjBzflList(orgCode);

		String startTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime1 = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		List<Universal> universalList = this.getUniversalList(startTime1, endTime1, orgCode);

		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime1 + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime1 + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);

		BigDecimal totalCout = mrInBasicMapper.getMrInBasicCount(mrInBasicQuery);

		String startTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2StartTime());
		String endTime2 = DateUtil.dateFormat(statisticalReportParam.getStatics2EndTime());
		List<Universal> preMonthUniversalList = this.getUniversalList(startTime2, endTime2, orgCode);

		String startTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3StartTime());
		String endTime3 = DateUtil.dateFormat(statisticalReportParam.getStatics3EndTime());
		List<Universal> lastYearMonthUniversalList = this.getUniversalList(startTime3, endTime3, orgCode);
		int count = 0;
		for (int i = 0; i < universalList.size(); i++) {
			QcAcquiredRecord qcAcquiredRecord = new QcAcquiredRecord();
			Universal universal = universalList.get(i);
			Universal preMonthUniversal = preMonthUniversalList.get(i);
			Universal lastYearMonthUniversal = lastYearMonthUniversalList.get(i);

			qcAcquiredRecord.setItem(universal.getName().split("-")[1]);
			qcAcquiredRecord.setNum(universal.getNum());
			qcAcquiredRecord.setPreMonthNum(preMonthUniversal.getNum());
			qcAcquiredRecord.setLastYearNum(lastYearMonthUniversal.getNum());
			if (universal.getCode().length() == 4) {
				qcAcquiredRecordList.add(qcAcquiredRecord);
				newQcAcquiredRecordList.add(qcAcquiredRecord);
				count += universal.getNum();
			}

		}

		qcAcquiredInfo.setQcAcquiredList(newQcAcquiredRecordList);

		Collections.sort(qcAcquiredRecordList, new Comparator<QcAcquiredRecord>() {

			@Override
			public int compare(QcAcquiredRecord o1, QcAcquiredRecord o2) {
				return o2.getNum() - o1.getNum();
			}
		});

		StringBuilder builder = new StringBuilder();
		builder.append("    住院患者医院获得性指标中医源性问题主要由手术并发症指标、患者安全类指标、产程和分娩期间并发症3部分组成，共包含了33组指标。")
				.append(statisticalReportParam.getStatics1Name()).append("出院诊断中符合医院获得性指标ICD-10编码的人数为").append(count)
				.append("人，其中，发生人数最多的3个获得性指标分别为");

		int index = 0;
		for (QcAcquiredRecord qcAcquiredRecord : qcAcquiredRecordList) {
			if (index == 0) {
				builder.append(qcAcquiredRecord.getItem()).append(qcAcquiredRecord.getNum()).append("人、");
			} else if (index == 1) {
				builder.append(qcAcquiredRecord.getItem()).append(qcAcquiredRecord.getNum()).append("人、");
			} else if (index == 2) {
				builder.append(qcAcquiredRecord.getItem()).append(qcAcquiredRecord.getNum())
						.append("人，按出院患者总人次计算的总发生率为");
			}

			index++;
		}

		builder.append(BigDecimalUtil.getDivideRate(new BigDecimal(count), totalCout)).append("%。");

		qcAcquiredInfo.setText(builder.toString());

		return qcAcquiredInfo;
	}

	public List<Universal> getUniversalList(String startTime, String endTime, String orgCode) {

		Map<String, String> params = new HashMap<>();
		params.put("orgcode", orgCode);
		params.put("start", startTime + " 00:00:00");
		params.put("end", endTime + " 23:59:59");
		params.put("outDepaId", null);
		params.put("leader", null);

		String json = HttpClientUtil.doPost("http://11.0.0.55:8999/medicalQuality/countByQcAcquired", params);

		logger.info("查询参数为:"+params);
		List<Universal> list = JsonUtil.jsonToList(json, Universal.class);

		return list;

	}

	/*
	 * public List<BaseForCount> getBaseForCount(String startTime, String endTime,
	 * String orgCode, List<TTjBzfl> tTjBzflList) { List<BaseForCount> bases = new
	 * ArrayList<BaseForCount>();
	 * 
	 * int jb_16 = 0; int jb_17 = 0; int jb_count16 = 0; int jb_count17 = 0; int
	 * index = 0;
	 * 
	 * for (TTjBzfl jbfl : tTjBzflList) {
	 * 
	 * BaseForCount base = new BaseForCount(); Integer count = 0; String order =
	 * jbfl.getYuliu2(); String bztype = jbfl.getType(); String jb_lei =
	 * jbfl.getLeimu(); String jb_ya = jbfl.getYamu(); String jb_xi =
	 * jbfl.getXimu(); String zdtype = jbfl.getYuliu3(); String num =
	 * jbfl.getYuliu1(); String name = jbfl.getName(); String companion =
	 * jbfl.getCompanion(); String type = jbfl.getBztype(); boolean jbzdFirstState =
	 * false;// 默认没有设置过，一旦设置过开头就要加or
	 * 
	 * StringBuffer sql_1 = new StringBuffer(); sql_1.append(" exists(");
	 * sql_1.append("select id from mr_in_diagnoss d where ");
	 * sql_1.append(" d.diag_type in(").append(zdtype).append(") "); if
	 * (StringUtil.isKeYongStr(jb_lei) || StringUtil.isKeYongStr(jb_ya) ||
	 * StringUtil.isKeYongStr(jb_xi)) { sql_1.append(" and ("); } if
	 * (StringUtil.isKeYongStr(jb_lei)) {
	 * sql_1.append(StringUtil.getDouhaoFengeForSql_HouLike("d.diag_code", jb_lei));
	 * jbzdFirstState = true; } if (StringUtil.isKeYongStr(jb_ya)) { if
	 * (jbzdFirstState) { sql_1.append("  or "); }
	 * sql_1.append(StringUtil.getDouhaoFengeForSql_HouLike("d.diag_code",
	 * jb_ya)).append(""); jbzdFirstState = true; } if
	 * (StringUtil.isKeYongStr(jb_xi)) { if (jbzdFirstState) {
	 * sql_1.append("  or "); }
	 * sql_1.append(StringUtil.getDouhaoFengeForSql("d.diag_code",
	 * jb_xi)).append(""); jbzdFirstState = true;
	 * 
	 * } if (StringUtil.isKeYongStr(jb_lei) || StringUtil.isKeYongStr(jb_ya) ||
	 * StringUtil.isKeYongStr(jb_xi)) { sql_1.append(" )"); } if ("3".equals(type))
	 * { sql_1.append(" and  d.status='4' "); }
	 * sql_1.append(" and d.serial_number=base.id"); sql_1.append(" ) "); if
	 * ("3.1".equals(bztype) || "3.4".equals(bztype) || "3.6".equals(bztype)) {
	 * sql_1.append(" and exists( "); sql_1.append(
	 * " select id from mr_in_operation o where o.serial_number=base.id and o.ops_sign in ('11','21') "
	 * ); sql_1.append(" ) "); } if (companion != null && !"".equals(companion)) {
	 * if ("3.6".equals(bztype)) { sql_1.append(" and not exists( "); } else {
	 * sql_1.append(" and  exists( "); }
	 * 
	 * sql_1.
	 * append(" select id from mr_in_operation o where o.serial_number=base.id  ");
	 * 
	 * if ("3.5".equals(bztype)) { sql_1.append(" and o.ops_sign ='21' and "); }
	 * else { sql_1.append(" and o.ops_sign in ('11','21') and "); } if
	 * (StringUtil.isKeYongStr(companion)) {
	 * 
	 * sql_1.append(StringUtil.getDouhaoFengeForSql("o.ops_code",
	 * companion)).append("");
	 * 
	 * }
	 * 
	 * sql_1.append(" ) "); } if ("3.2".equals(bztype)) { sql_1.
	 * append(" and  to_number( to_date(to_char(base.in_time,'yyyy-mm-dd'),'yyyy-mm-dd')-"
	 * ); sql_1.
	 * append(" to_date(to_char(base.birthday,'yyyy-mm-dd'),'yyyy-mm-dd') )<=28");
	 * 
	 * } if ("3.7".equals(bztype)) { sql_1.append(" and exists( "); sql_1.append(
	 * " select id from mr_in_diagnoss d where d.serial_number=base.id and d.diag_code like 'Z37%' "
	 * ); sql_1.append(" ) "); } if ("16".equals(order)) { jb_16 = index; } else if
	 * ("17".equals(order)) { jb_17 = index; } else { count =
	 * mrInBasicMapper.getCount(startTime, endTime, sql_1.toString(), orgCode); }
	 * 
	 * base.setCount(count); base.setName(order.toString() + "-" + name); if
	 * (!order.contains(".")) { index++; bases.add(base);
	 * 
	 * }
	 * 
	 * if (order.contains("16.")) { jb_count16 += count; } else if
	 * (order.contains("17.")) { jb_count17 += count; }
	 * System.out.println(base.getName() + "-" + base.getCount()); }
	 * bases.get(jb_16).setCount(jb_count16); bases.get(jb_17).setCount(jb_count17);
	 * 
	 * return bases; }
	 */

	@Override
	public Major20DiagInfo getMajor20OperationInfo(StatisticalReportParam statisticalReportParam, String orgCode) {
		Major20DiagInfo major20DiagInfo = new Major20DiagInfo();
		String startTime = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);

		BigDecimal totalCout = mrInBasicMapper.getMrInBasicCount(mrInBasicQuery);

		List<MedicalQuality> medicalQualityList = this.getMedicalQualityList(startTime, endTime, orgCode, "3");
		if (CollectionUtils.isEmpty(medicalQualityList)) {
			return null;
		}
		int total20Num = 0;
		for (MedicalQuality medicalQuality : medicalQualityList) {
			total20Num += medicalQuality.getSurgicalN();
			if (medicalQuality.getSurgicalN() != null && medicalQuality.getDeathSurgicalN() != null) {
				if (medicalQuality.getSurgicalN() == 0) {
					medicalQuality.setDeathRate(new BigDecimal(0));
				} else {
					medicalQuality.setDeathRate(
							BigDecimalUtil.getDivideRate(new BigDecimal(medicalQuality.getDeathSurgicalN()),
									new BigDecimal(medicalQuality.getSurgicalN())));
				}

			}
		}

		major20DiagInfo.setList(medicalQualityList);

		BigDecimal total20NumRate = BigDecimalUtil.getDivideRate(new BigDecimal(total20Num), totalCout);

		StringBuilder builder = new StringBuilder();
		builder.append("    " + statisticalReportParam.getStatics1Name()).append("20个重点手术所覆盖的住院患者人数为")
				.append(total20Num).append("人，占出院患者总数的").append(total20NumRate).append("%。").append("其中人次数最多的3种手术分别为");

		// 出院人数最多
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return o2.getSurgicalN() - o1.getSurgicalN();
			}
		});

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 死亡人数最多的3种手术
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return o2.getDeathSurgicalN() - o1.getDeathSurgicalN();
			}
		});

		builder.append("死亡人数最多的3种手术分别");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 病死率最高的3种手术
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return o2.getDeathRate().compareTo(o1.getDeathRate());
			}
		});

		builder.append("病死率最高的3种手术分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 病死率最高的3种手术
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return o2.getuPlanReturnInMonth() - o1.getuPlanReturnInMonth();
			}
		});

		int uPlanReturnInMonth = 0;

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				if (medicalQuality.getuPlanReturnInMonth() > 0) {
					uPlanReturnInMonth++;
				}
			} else if (i == 1) {
				if (medicalQuality.getuPlanReturnInMonth() > 0) {
					uPlanReturnInMonth++;
				}
			} else if (i == 2) {
				if (medicalQuality.getuPlanReturnInMonth() > 0) {
					uPlanReturnInMonth++;
				}
			}
		}

		if (uPlanReturnInMonth == 0) {
			builder.append("20个重点手术均无术后31天非计划重返手术室手术的患者；");
		} else if (uPlanReturnInMonth > 0) {
			builder.append("20个重点手术最多的" + uPlanReturnInMonth + "种术后31天非计划重返手术室手术的患者为");
			for (int i = 1; i <= 3; i++) {
				if (i > uPlanReturnInMonth) {
					continue;
				}
				MedicalQuality medicalQuality = medicalQualityList.get(i);
				if (i == 0) {
					if (medicalQuality.getuPlanReturnInMonth() > 0) {
						uPlanReturnInMonth++;
					}
				} else if (i == 1) {
					if (medicalQuality.getuPlanReturnInMonth() > 0) {
						uPlanReturnInMonth++;
					}
				} else if (i == 2) {
					if (medicalQuality.getuPlanReturnInMonth() > 0) {
						uPlanReturnInMonth++;
					}
				}
			}

		}

		// 平均住院天数最多的3种手术分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return  new BigDecimal(o2.getAverageStay()).compareTo(new BigDecimal(o1.getAverageStay()));
			}
		});

		builder.append("平均住院天数最多的3种手术分别为");

		for (int i = 0; i <= 2; i++) {
			
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 平均住院天数最少的3种手术分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return  new BigDecimal(o1.getAverageStay()).compareTo(new BigDecimal(o2.getAverageStay()));
			}
		});

		builder.append("平均住院天数最少的3种手术分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 平均住院费用最高的3个手术分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o2.getCostPer() - o1.getCostPer());
			}
		});

		builder.append("平均住院费用最高的3个手术分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 平均住院费用最少的3个手术分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o1.getCostPer() - o2.getCostPer());
			}
		});

		builder.append("平均住院费用最少的3个手术分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append("。");
			}
		}

		major20DiagInfo.setText(builder.toString());

		return major20DiagInfo;
	}

	@Override
	public Major20DiagInfo getMajor20DiagInfo(StatisticalReportParam statisticalReportParam, String orgCode) {

		Major20DiagInfo major20DiagInfo = new Major20DiagInfo();
		String startTime = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);

		BigDecimal totalCout = mrInBasicMapper.getMrInBasicCount(mrInBasicQuery);

		List<MedicalQuality> medicalQualityList = this.getMedicalQualityList(startTime, endTime, orgCode, "2");
		if (CollectionUtils.isEmpty(medicalQualityList)) {
			return null;
		}
		int total20Num = 0;
		for (MedicalQuality medicalQuality : medicalQualityList) {
			total20Num += medicalQuality.getDischarges();
			if (medicalQuality.getDischarges() != null && medicalQuality.getDeaths() != null) {
				medicalQuality.setDeathRate(BigDecimalUtil.getDivideRate(new BigDecimal(medicalQuality.getDeaths()),
						new BigDecimal(medicalQuality.getDischarges())));
			}
		}

		major20DiagInfo.setList(medicalQualityList);

		BigDecimal total20NumRate = BigDecimalUtil.getDivideRate(new BigDecimal(total20Num), totalCout);

		StringBuilder builder = new StringBuilder();
		builder.append("     " + statisticalReportParam.getStatics1Name()).append("20个重点病种所覆盖的住院患者人数为")
				.append(total20Num).append("人，占出院患者总数的").append(total20NumRate).append("%。其中，出院患者人数最多的3种疾病分别为");

		// 出院人数最多
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return o2.getDischarges() - o1.getDischarges();
			}
		});

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 死亡人数最多
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return o2.getDeaths() - o1.getDeaths();
			}
		});

		builder.append("死亡人数最多的3种疾病分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 病死率最高的3种疾病分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return o2.getDeathRate().compareTo(o1.getDeathRate());
			}
		});

		builder.append("病死率最高的3种疾病分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 平均住院天数最多的3种疾病分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {
			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return  new BigDecimal(o2.getAverageStay()).compareTo(new BigDecimal(o1.getAverageStay()));
			}
		});

		builder.append("平均住院天数最多的3种疾病分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 平均住院天数最少的3种疾病分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return  new BigDecimal(o1.getAverageStay()).compareTo(new BigDecimal(o2.getAverageStay()));
			}
		});

		builder.append("平均住院天数最少的3种疾病分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 平均住院费用最高的3种疾病分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o2.getCostPer() - o1.getCostPer());
			}
		});

		builder.append("平均住院费用最高的3种疾病分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 平均住院费用最少的3种疾病分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o1.getCostPer() - o2.getCostPer());
			}
		});

		builder.append("平均住院费用最少的3种疾病分别为");

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		major20DiagInfo.setText(builder.toString());

		return major20DiagInfo;
	}

	@Override
	public Major20DiagInfo getMajorTumourNonOpInfo(StatisticalReportParam statisticalReportParam, String orgCode) {
		Major20DiagInfo major20DiagInfo = new Major20DiagInfo();
		String startTime = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);

		BigDecimal totalCout = mrInBasicMapper.getMrInBasicCount(mrInBasicQuery);

		List<MedicalQuality> medicalQualityList = this.getMedicalQualityList(startTime, endTime, orgCode, "4");
		if (CollectionUtils.isEmpty(medicalQualityList)) {
			return null;
		}
		int total20Num = 0;
		for (MedicalQuality medicalQuality : medicalQualityList) {
			total20Num += medicalQuality.getDischarges();
			if (medicalQuality.getDischarges() != null && medicalQuality.getDeaths() != null) {
				medicalQuality.setDeathRate(BigDecimalUtil.getDivideRate(new BigDecimal(medicalQuality.getDeaths()),
						new BigDecimal(medicalQuality.getDischarges())));
			}
		}

		major20DiagInfo.setList(medicalQualityList);

		BigDecimal total20NumRate = BigDecimalUtil.getDivideRate(new BigDecimal(total20Num), totalCout);

		StringBuilder builder = new StringBuilder();
		builder.append("    肿瘤非手术治疗指标是指通过放疗、化疗、介入、生物治疗、内分泌治疗、中医中药治疗、热疗和射频消融等（非外科手术切除）方法治疗肿瘤的相关结果性指标。\n");
		builder.append("    " + statisticalReportParam.getStatics1Name()).append("16个重点肿瘤非手术治疗人数为").append(total20Num)
				.append("人，占总出院人数的").append(total20NumRate).append("%,其中人数最多的3种恶性肿瘤分别为");

		// 其中人数最多的3种恶性肿瘤分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o2.getDischarges() - o1.getDischarges());
			}
		});

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 死亡人数
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o2.getDeaths() - o1.getDeaths());
			}
		});

		int deathCount = 0;

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0 && medicalQuality.getDeaths() > 0) {
				deathCount++;
			} else if (i == 1 && medicalQuality.getDeaths() > 0) {
				deathCount++;
			} else if (i == 2 && medicalQuality.getDeaths() > 0) {
				deathCount++;
			}
		}

		if (deathCount == 0) {
			builder.append("所涉及的16种恶性肿瘤非手术治疗患者无在院死亡情况;");
		} else {
			builder.append("恶性肿瘤非手术治疗患者在院死亡较多" + deathCount + "种肿瘤为");
			for (int i = 1; i <= 3; i++) {
				if (i > deathCount)
					continue;
				MedicalQuality medicalQuality = medicalQualityList.get(i);
				if (i == 1) {
					builder.append(medicalQuality.getSpeciesN()).append("、");
				} else if (i == 2) {
					builder.append(medicalQuality.getSpeciesN()).append("、");
				} else if (i == 3) {
					builder.append(medicalQuality.getSpeciesN()).append(";");
				}
			}
		}

		// 0~31天再入院情况
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (o2.getUnexpectedDay() + o2.getUnexpectedDayT() + o2.getUnexpectedDayS())
						- (o1.getUnexpectedDay() + o1.getUnexpectedDayT() + o1.getUnexpectedDayS());
			}
		});

		int unExpectCount = 0;

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0 && (medicalQuality.getUnexpectedDay() + medicalQuality.getUnexpectedDayT()
					+ medicalQuality.getUnexpectedDayS()) > 0) {
				unExpectCount++;
			} else if (i == 1 && (medicalQuality.getUnexpectedDay() + medicalQuality.getUnexpectedDayT()
					+ medicalQuality.getUnexpectedDayS()) > 0) {
				unExpectCount++;
			} else if (i == 2 && (medicalQuality.getUnexpectedDay() + medicalQuality.getUnexpectedDayT()
					+ medicalQuality.getUnexpectedDayS()) > 0) {
				unExpectCount++;
			}
		}

		if (unExpectCount == 0) {
			builder.append("无0~31天再入院情况;");
		} else {
			builder.append("其中0~31天再入院肿瘤疾病分别为");
			for (int i = 1; i <= 3; i++) {
				if (i > unExpectCount)
					continue;
				MedicalQuality medicalQuality = medicalQualityList.get(i);
				if (i == 1) {
					builder.append(medicalQuality.getSpeciesN()).append("、");
				} else if (i == 2) {
					builder.append(medicalQuality.getSpeciesN()).append("、");
				} else if (i == 3) {
					builder.append(medicalQuality.getSpeciesN()).append(";");
				}
			}
		}

		// 平均住院天数最多
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return  new BigDecimal(o2.getAverageStay()).compareTo(new BigDecimal(o1.getAverageStay()));
			}
		});

		builder.append("平均住院天数最多的3种疾病分别为");
		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			} else {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			}

		}

		// 平均住院天数最少
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return  new BigDecimal(o1.getAverageStay()).compareTo(new BigDecimal(o2.getAverageStay()));
			}
		});

		builder.append("平均住院天数最少的3种疾病分别为");
		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			} else {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			}

		}

		// 平均住院费用最高的3种疾病
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o2.getCostPer() - o1.getCostPer());
			}
		});

		builder.append("平均住院费用最高的3种疾病分别为");
		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			} else {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			}

		}

		// 平均住院费用最低的3种疾病
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o1.getCostPer() - o2.getCostPer());
			}
		});

		builder.append("平均住院费用最低的3种疾病分别为");
		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			} else {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			}

		}

		major20DiagInfo.setText(builder.toString());

		return major20DiagInfo;
	}

	@Override
	public Major20DiagInfo getMajorTumourOpInfo(StatisticalReportParam statisticalReportParam, String orgCode) {
		Major20DiagInfo major20DiagInfo = new Major20DiagInfo();
		String startTime = DateUtil.dateFormat(statisticalReportParam.getStatics1StartTime());
		String endTime = DateUtil.dateFormat(statisticalReportParam.getStatics1EndTime());
		MrInBasicQuery mrInBasicQuery = new MrInBasicQuery();
		mrInBasicQuery.setStartDateStr(startTime + " 00:00:00");
		mrInBasicQuery.setEndDateStr(endTime + " 23:59:59");
		mrInBasicQuery.setOrgCode(orgCode);

		BigDecimal totalCout = mrInBasicMapper.getMrInBasicCount(mrInBasicQuery);

		List<MedicalQuality> medicalQualityList = this.getMedicalQualityList(startTime, endTime, orgCode, "5");
		if (CollectionUtils.isEmpty(medicalQualityList)) {
			return null;
		}
		int total20Num = 0;
		List<MedicalQuality> newMedicalQualityList = new LinkedList<MedicalQuality>();
		for (MedicalQuality medicalQuality : medicalQualityList) {
			newMedicalQualityList.add(medicalQuality);
			total20Num += medicalQuality.getSurgicalN();

		}

		major20DiagInfo.setList(newMedicalQualityList);

		BigDecimal total20NumRate = BigDecimalUtil.getDivideRate(new BigDecimal(total20Num), totalCout);

		StringBuilder builder = new StringBuilder();
		builder.append("    恶性肿瘤住院手术治疗指标是通过外科手术切除来治疗肿瘤的相关结果性指标。\n");
		builder.append("    " + statisticalReportParam.getStatics1Name()).append("14个重点肿瘤手术治疗人数为").append(total20Num)
				.append("人，占总出院人数的").append(total20NumRate).append("%,其中人数最多的3种肿瘤分别为");

		// 其中人数最多的3种恶性肿瘤分别为
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o2.getSurgicalN() - o1.getSurgicalN());
			}
		});

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 1) {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			} else if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			}
		}

		// 死亡人数
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o2.getDeathSurgicalN() - o1.getDeathSurgicalN());
			}
		});

		int deathCount = 0;

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0 && medicalQuality.getDeathSurgicalN() > 0) {
				deathCount++;
			} else if (i == 1 && medicalQuality.getDeathSurgicalN() > 0) {
				deathCount++;
			} else if (i == 2 && medicalQuality.getDeathSurgicalN() > 0) {
				deathCount++;
			}
		}

		if (deathCount == 0) {
			builder.append("无患者死亡;");
		} else {
			builder.append("有患者死亡的病种为");
			for (int i = 1; i <= 3; i++) {
				if (i > deathCount)
					continue;
				MedicalQuality medicalQuality = medicalQualityList.get(i);
				if (i == 1) {
					builder.append(medicalQuality.getSpeciesN()).append(medicalQuality.getDeathSurgicalN()).append("人")
							.append(i == deathCount ? ";" : "、");
				} else if (i == 2) {
					builder.append(medicalQuality.getSpeciesN()).append(medicalQuality.getDeathSurgicalN()).append("人")
							.append(i == deathCount ? ";" : "、");
				} else if (i == 3) {
					builder.append(medicalQuality.getSpeciesN()).append(medicalQuality.getDeathSurgicalN())
							.append("人;");
				}
			}
		}

		// 0~31天再入院情况
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (o2.getUnexpectedDay() + o2.getUnexpectedDayT() + o2.getUnexpectedDayS())
						- (o1.getUnexpectedDay() + o1.getUnexpectedDayT() + o1.getUnexpectedDayS());
			}
		});

		// 平均住院天数最多
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return  new BigDecimal(o2.getAverageStay()).compareTo(new BigDecimal(o1.getAverageStay()));
			}
		});

		builder.append("平均住院天数最多的3种肿瘤分别为");
		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			} else {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			}

		}

		// 平均住院天数最少
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return  new BigDecimal(o1.getAverageStay()).compareTo(new BigDecimal(o2.getAverageStay()));
			}
		});

		builder.append("平均住院天数最少的3种肿瘤分别为");
		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			} else {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			}

		}

		// 平均住院费用最高的3种疾病
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o2.getCostPer() - o1.getCostPer());
			}
		});

		builder.append("平均住院费用最高的3种肿瘤分别为");
		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			} else {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			}

		}

		// 平均住院费用最低的3种疾病
		Collections.sort(medicalQualityList, new Comparator<MedicalQuality>() {

			@Override
			public int compare(MedicalQuality o1, MedicalQuality o2) {
				return (int) (o1.getCostPer() - o2.getCostPer());
			}
		});

		builder.append("平均住院费用最少的3种肿瘤分别为");
		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 2) {
				builder.append(medicalQuality.getSpeciesN()).append(";");
			} else {
				builder.append(medicalQuality.getSpeciesN()).append("、");
			}

		}

		int unExpectCount = 0;

		for (int i = 0; i <= 2; i++) {
			MedicalQuality medicalQuality = medicalQualityList.get(i);
			if (i == 0 && (medicalQuality.getuPlanReturn2() + medicalQuality.getuPlanReturn3()) > 0) {
				unExpectCount++;
			} else if (i == 1 && (medicalQuality.getUnexpectedDay() + medicalQuality.getUnexpectedDayT()
					+ medicalQuality.getUnexpectedDayS()) > 0) {
				unExpectCount++;
			} else if (i == 2 && (medicalQuality.getUnexpectedDay() + medicalQuality.getUnexpectedDayT()
					+ medicalQuality.getUnexpectedDayS()) > 0) {
				unExpectCount++;
			}
		}

		if (unExpectCount == 0) {
			builder.append("14个重点恶性肿瘤手术治疗患者均无非计划再次重返手术室手术的情况。");
		} else {
			builder.append("其中0~31天再入院肿瘤疾病分别为");
			for (int i = 1; i <= 3; i++) {
				if (i > unExpectCount)
					continue;
				MedicalQuality medicalQuality = medicalQualityList.get(i);
				if (i == 1) {
					builder.append(medicalQuality.getSpeciesN()).append("、");
				} else if (i == 2) {
					builder.append(medicalQuality.getSpeciesN()).append("、");
				} else if (i == 3) {
					builder.append(medicalQuality.getSpeciesN()).append(";");
				}
			}
		}

		major20DiagInfo.setText(builder.toString());

		return major20DiagInfo;
	}

	public List<MedicalQuality> getMedicalQualityList(String startTime, String endTime, String orgCode, String code) {

		List<StdQcIndex> StdQcIndexList = this.getStdQcIndexList(code);
		List<MedicalQuality> medicalQualityList = new LinkedList<MedicalQuality>();
		MedicalQuality medicalQuality = null;

		for (StdQcIndex stdQcIndex : StdQcIndexList) {
			String name = stdQcIndex.getName();
			
			//20种重点疾病
			if ("2".equals(code)) {
				String [] mainDiag20Arr = Constant.MAIN_TOP20_DIAGS;
				List<String> mainDiag20List = Arrays.asList(mainDiag20Arr);
				if(!mainDiag20List.contains(name)) {
					continue;
				}
				
			//20个重点手术	
			}else if ("3".equals(code)){
				String [] arr = Constant.MAIN_TOP20_OPERATION;
				List<String> list = Arrays.asList(arr);
				if(!list.contains(name)) {
					continue;
				}
			//	16个重点肿瘤非手术治疗
			}else if ("4".equals(code)){
				String [] arr = Constant.MAJOR_TUMOUR_TOP16_NON_OPERATION_CURE;
				List<String> list = Arrays.asList(arr);
				if(!list.contains(name)) {
					continue;
				}
			//14个重点恶性肿瘤住院手术治疗相关指标	
			}else if ("5".equals(code)){
				String [] arr = Constant.MAJOR_TUMOUR_TOP14_OPERATION_CURE;
				List<String> list = Arrays.asList(arr);
				if(!list.contains(name)) {
					continue;
				}
			}

			medicalQuality = this.getMedicalQuality(startTime, endTime, orgCode, code, stdQcIndex.getId().toString());

			System.out.println(medicalQuality);

			if (medicalQuality != null)
				medicalQuality.setSpeciesN(stdQcIndex.getName());
			medicalQualityList.add(medicalQuality);

		}

		return medicalQualityList;
	}

	public List<StdQcIndex> getStdQcIndexList(String code) {
		List<StdQcIndex> stdQcIndexList = new LinkedList<StdQcIndex>();
		try {
			Map<String, String> params = new HashMap<>();
			params.put("code", code);
			String json = HttpClientUtil.doPost("http://11.0.0.55:8999/medicalQuality/getStdQcIndexByCode", params);
			stdQcIndexList = JsonUtil.jsonToList(json, StdQcIndex.class);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return stdQcIndexList;

	}

	public MedicalQuality getMedicalQuality(String start, String end, String orgCode, String jumpParam,
			String stdQcIndex) {
		Map<String, String> params = new HashMap<>();
		params.put("orgcode", orgCode);
		params.put("start", start + " 00:00:00");
		params.put("end", end + " 23:59:59");
		params.put("outDepaId", null);
		params.put("leader", null);
		params.put("jumpParam", jumpParam);
		params.put("stdQcIndex", stdQcIndex);

		String json = HttpClientUtil.doPost("http://11.0.0.55:8999/medicalQuality/countByQcFocalPoint", params);

		List<MedicalQuality> medicalQualityList = JsonUtil.jsonToList(json, MedicalQuality.class);

		if (CollectionUtils.isEmpty(medicalQualityList)) {
			return new MedicalQuality();
		}

		return medicalQualityList.get(0);

	}
	
	
	/** 质量统计-绩效考核 **/
	public Performance performanceData(final String yybm,
			CybingrenTJSearch cybrSearch) {
		final Performance performance=new Performance();
		final String existsSql = TongJiSaqlUtil.disFeiyong(yybm, cybrSearch);
		ExecutorService threadPool = Executors.newFixedThreadPool(11);
		CompletionService<Integer> completionService = new ExecutorCompletionService<Integer>(threadPool);
	    for (int j = 1; j <= 11; j++) {

	        final int index = j;
	        completionService.submit(new Callable<Integer>() {
	            public Integer call() throws Exception {
	            	if (index == 1) {
	                	System.out.println("手术人数："+existsSql+performanceSql("opsrs"));

	            		Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("opsrs"), yybm);
	            		if(count==null){
	            			count =0;
	            		}
	            		performance.setOpsrs(count);
	                }
	            	if (index == 2) {
	            		System.out.println("介入手术："+existsSql+performanceSql("intervene"));
	            		Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("intervene"), yybm);
	            		if(count==null){
	            			count =0;
	            		}
	            		performance.setIntervene(count);
	                }
	                //第三个线程睡眠等待
	                if (index == 3) {
	                	System.out.println("微创"+existsSql+performanceSql("mini"));

	            		Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("mini"), yybm);
	            		if(count==null){
	            			count =0;
	            		}
	            		performance.setMini(count);
	                }
	                if (index == 4) {
	                	Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("sjrs"), yybm);
	            		if(count==null){
	            			count =0;
	            		}
	                	performance.setSjrs(count);
	                }
	                if (index == 5) {
	                	Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("complication"), yybm);
	            		if(count==null){
	            			count =0;
	            		}
	                	performance.setComplication(count);	               
	            	}
	                if (index == 6) {
	                	Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("complicationD"), yybm);
	            		if(count==null){
	            			count =0;
	            		}
	                	performance.setComplicationD(count);	               
	            	}
	                if (index == 7) {
	                	Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("infectionI"), yybm);
	            		if(count==null){
	            			count =0;
	            		}
	                	performance.setInfectionI(count);
	            	}
	                if (index == 8) {
	                	Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("infectionID"), yybm);
	            		if(count==null){
	            			count =0;
	            		}
	                	performance.setInfectionID(count);	               
	            	}
	                if (index == 9) {
	                	Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("elective"), yybm);
	            		if(count==null){
	            			count =0;
	            		}
	                	performance.setElective(count);	               
	            	}
	                if (index == 10) {
	                	Integer count = tBaBaseMapper.getPerformanceData(existsSql, yybm);
	            		if(count==null){
	            			count =0;
	            		}
	                	performance.setCyrs(count);	               
	            	}
	                if (index == 11) {
	                	Performance per = tBnssczMapper.getPerformanceData(existsSql, yybm);
	                			
	            		if(per!=null){
	            			performance.setInterveneRcs(per.getInterveneRcs());
	            			performance.setMiniRcs(per.getMiniRcs());
	            		}
	                	        
	            	}
	                return index;
	            }
	        });
	    }
	    threadPool.shutdown();
	    System.out.println("线程开始");
	    for (int i = 0; i < 11; i++) {
	        try {
	            System.out.println("线程:"+completionService.take().get()+" 任务执行结束:");
	        } catch (InterruptedException e) {
	            e.printStackTrace();
	        } catch (ExecutionException e) {
	            e.printStackTrace();
	        }
	    }
	    System.out.println("线程结束");
	    performance.initDate();
		return performance;
	}
	
	private String performanceSql(String type){
		StringBuffer sql=new StringBuffer();
		if("opsrs".equals(type)){
			sql.append(" and exists( select o.id from mr_in_operation o left join stdopsoperation_ ops on o.ops_code=ops.code_ ");
			sql.append(" and ops.attributes_='40' where base.id=o.serial_number and ops.stdopsoperationmark_ in('11','211')  ");
			sql.append(" ) ");
			
		}else if("intervene".equals(type)){
			sql.append(" and exists( select o.id from mr_in_operation o left join stdopsoperation_ ops on o.ops_code=ops.code_ ");
			sql.append(" and ops.attributes_='40' where base.id=o.serial_number and ops.stdopsoperationmark_ ='211'  ) ");
		}else if("mini".equals(type)){
			sql.append(" and exists( select o.id from mr_in_operation o ");
			sql.append(" left join stdopsoperation_ ops on o.ops_code=ops.code_ ");
			sql.append(" and ops.attributes_='40' where base.id=o.serial_number ");
			sql.append(" and ops.mini_surgery='1'  ) ");
		}else if("sjrs".equals(type)){
/*			sql.append(" and exists( select o.id from mr_in_operation o ");
			sql.append(" left join stdopsoperation_ ops on o.ops_code=ops.code_ ");
			sql.append(" and ops.attributes_='40' where base.id=o.serial_number ");
			sql.append(" and ops.opslevel_national='4'  )");*/
			
			sql.append(" and exists ( ");
			sql.append(" select o.id ");
			sql.append("  from mr_in_operation o ");
			sql.append(" where ");
			sql.append("  ( exists( ");
			sql.append(" select id from stdopsoperation_ ops ");
			sql.append("  where ");
			sql.append(" (o.ops_code = ops.code_ ");
			sql.append(" or o.ops_code_1=ops.code_ ");
			sql.append("  or o.ops_code_2=ops.code_  ");
			sql.append(" ) ");
			sql.append("  and ops.attributes_ = '40' ");
			sql.append(" and base.id = o.serial_number ");
			sql.append("  and ops.opslevel_national = '4' ");
			sql.append("   ) ");
			sql.append("  ) ");
			sql.append("  ) ");
		}else if("complication".equals(type)){
			sql.append(" and exists(select o.id from mr_in_operation o ");
			sql.append(" left join stdopsoperation_ ops");
			sql.append("      on o.ops_code=ops.code_");
			sql.append(" and ops.attributes_='40'");
			sql.append(" where base.id=o.serial_number");
			sql.append(" and ops.stdopsoperationmark_ ='11') ");
			       
			sql.append(" and exists( ");
			sql.append(" select d.id from mr_in_diagnoss d ");
			sql.append(" left join stddisease_ dis ");
			sql.append("      on d.diag_code=dis.code_ ");
			sql.append(" where dis.qc_flag='1' ");
			sql.append(" and d.serial_number=base.id ");
			sql.append(" and d.status='4' ");
			sql.append(" and d.diag_code not like 'O%') ");
			sql.append(" and base.in_way!='1' ");
			sql.append(" and (base.age_day is null or base.age_day>28) ");
		}else if("complicationD".equals(type)){
			sql.append(" and exists(select o.id from mr_in_operation o ");
			sql.append(" left join stdopsoperation_ ops");
			sql.append("      on o.ops_code=ops.code_");
			sql.append(" and ops.attributes_='40'");
			sql.append(" where base.id=o.serial_number");
			sql.append(" and ops.stdopsoperationmark_ ='11') ");
			       
			sql.append(" and not exists( ");
			sql.append(" select d.id from mr_in_diagnoss d ");
			sql.append(" where d.diag_code like 'O%' ");
			sql.append(" and base.id=d.serial_number) ");
			sql.append(" and base.in_way!='1' ");
			sql.append(" and (base.age_day is null or base.age_day>28) ");

		}else if("infectionI".equals(type)){
			sql.append(" and exists( ");
			sql.append(" select o.id from mr_in_operation o");
			sql.append("  left join stdopsoperation_ ops");
			sql.append(" on o.ops_code=ops.code_");
			sql.append(" and ops.attributes_='40'");
			sql.append(" where base.id=o.serial_number");
			sql.append(" and ops.stdopsoperationmark_ ='11'");
			sql.append(" and o.incision_healing='3')");
		}else if("infectionID".equals(type)){
			sql.append(" and exists( ");
			sql.append(" select o.id from mr_in_operation o");
			sql.append("  left join stdopsoperation_ ops");
			sql.append(" on o.ops_code=ops.code_");
			sql.append(" and ops.attributes_='40'");
			sql.append(" where base.id=o.serial_number");
			sql.append(" and ops.stdopsoperationmark_ ='11'");
			sql.append(" and o.incision_healing in('1','2','3','10'))");
			
		}else if("elective".equals(type)){
			sql.append(" and exists( ");
			sql.append(" select o.id from mr_in_operation o");
			sql.append("  left join stdopsoperation_ ops");
			sql.append(" on o.ops_code=ops.code_");
			sql.append(" and ops.attributes_='40'");
			sql.append(" where base.id=o.serial_number");
			sql.append(" and ops.stdopsoperationmark_ in ('11','211') ");
			sql.append(" and base.in_way!='1') ");
		}
		return sql.toString();
	}
	

	@Override
	public void deleteParamSettingById(Integer id) {
		
		statisticalReportParamMapper.deleteByPrimaryKey(id);
	}

	@Override
	public GeneralPerformace getPerformanceGeneral(StatisticalReportParam statisticalReportParam,String orgCode) {
		
		
		GeneralPerformace generalPerformace = new GeneralPerformace();
	
		
		CybingrenTJSearch cybingrenTJSearch1 = new CybingrenTJSearch();
		cybingrenTJSearch1.setChuyuanrqStart(statisticalReportParam.getStatics1StartTime());
		cybingrenTJSearch1.setChuyuanrqEnd(statisticalReportParam.getStatics1EndTime());
		Performance performance = performanceData(orgCode, cybingrenTJSearch1);
		
		generalPerformace.setNowPerformace(performance);
		
		
		CybingrenTJSearch cybingrenTJSearch2 = new CybingrenTJSearch();
		cybingrenTJSearch2.setChuyuanrqStart(statisticalReportParam.getStatics2StartTime());
		cybingrenTJSearch2.setChuyuanrqEnd(statisticalReportParam.getStatics2EndTime());
		Performance performance2 = performanceData(orgCode, cybingrenTJSearch2);
		
		generalPerformace.setPrePerformace(performance2);
		
		
		CybingrenTJSearch cybingrenTJSearch3 = new CybingrenTJSearch();
		cybingrenTJSearch3.setChuyuanrqStart(statisticalReportParam.getStatics3StartTime());
		cybingrenTJSearch3.setChuyuanrqEnd(statisticalReportParam.getStatics3EndTime());
		Performance performance3 = performanceData(orgCode, cybingrenTJSearch3);
		generalPerformace.setLastPerformace(performance3);
		
		
		String note = "按照三级公立医院绩效考核标准，"+statisticalReportParam.getStatics1Name()+"出院患者手术占比为"+performance.getOpsrsLv()+"%，微创手术占比为"+performance.getMiniLv()+"%，四级手术占比为"+performance.getSjrsLv()+"%；手术患者并发症发生率为"+performance.getComplicationLv()+"%，I类切口手术部位感染率为"+performance.getInfectionILv()+"%。";
		
		generalPerformace.setNote(note);
		
		System.out.println("本月:"+performance);
		System.out.println("上月:"+performance2);
		System.out.println("去年同月:"+performance3);
		
		return generalPerformace;
	}

	@Override
	public PerformanceInfo getSsrsPerformance(StatisticalReportParam statisticalReportParam, String orgCode) {
		
		PerformanceInfo performanceInfo = new PerformanceInfo();
		
		Map<String,String> surgialDepas = Constant.SURGICAL_DEPARTMENT_MAP;
		
		
		SsrsPerformance ssrsPerformance = null;
		
		List<SsrsPerformance> ssrsPerformanceList = new ArrayList<>();
		
		for (Map.Entry<String, String> m : surgialDepas.entrySet()) {
			ssrsPerformance = new SsrsPerformance();
			String deptCode = m.getKey();
			String deptName = m.getValue();
			ssrsPerformance.setDepa(deptName);
			ssrsPerformance.setDepaCode(deptCode);
			
			String deptSql1 = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics1StartTime(),statisticalReportParam.getStatics1EndTime(),deptCode));
			Integer ssrsCount = tBaBaseMapper.getPerformanceData(deptSql1+performanceSql("opsrs"), orgCode);
			ssrsPerformance.setOpsrs(ssrsCount);
			Integer cyrsCount = tBaBaseMapper.getPerformanceData(deptSql1, orgCode);
			ssrsPerformance.setCyrs(cyrsCount);
		
			String preDeptSql1 = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics2StartTime(),statisticalReportParam.getStatics2EndTime(),deptCode));
			Integer preSsrsCount = tBaBaseMapper.getPerformanceData(preDeptSql1+performanceSql("opsrs"), orgCode);
			ssrsPerformance.setPreOpsrs(preSsrsCount);
			Integer preCyrsCount = tBaBaseMapper.getPerformanceData(preDeptSql1, orgCode);
			ssrsPerformance.setPreCyrs(preCyrsCount);
			
			String lastDeptSql1 = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics3StartTime(),statisticalReportParam.getStatics3EndTime(),deptCode));
			Integer lastSsrsCount = tBaBaseMapper.getPerformanceData(lastDeptSql1+performanceSql("opsrs"), orgCode);
			ssrsPerformance.setLastOpsrs(lastSsrsCount);
			Integer lastCyrsCount = tBaBaseMapper.getPerformanceData(lastDeptSql1, orgCode);
			ssrsPerformance.setLastCyrs(lastCyrsCount);
			
			
			ssrsPerformance.initDate();
			ssrsPerformanceList.add(ssrsPerformance);
			System.out.println(ssrsPerformance);  
		}
		

		String existsSql = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics1StartTime(),statisticalReportParam.getStatics1EndTime(),null));
		
		Integer count = tBaBaseMapper.getPerformanceData(existsSql+performanceSql("opsrs"), orgCode);
		Integer cyrsCount = tBaBaseMapper.getPerformanceData(existsSql, orgCode);
		
		String preTotalSql = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics2StartTime(),statisticalReportParam.getStatics2EndTime(),null));
		Integer preCount = tBaBaseMapper.getPerformanceData(preTotalSql+performanceSql("opsrs"), orgCode);
		Integer preCyrsCount = tBaBaseMapper.getPerformanceData(preTotalSql, orgCode);
		
		String lastTotalSql = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics3StartTime(),statisticalReportParam.getStatics3EndTime(),null));
		Integer lastCount = tBaBaseMapper.getPerformanceData(lastTotalSql+performanceSql("opsrs"), orgCode);
		Integer lastCyrsCount = tBaBaseMapper.getPerformanceData(lastTotalSql, orgCode);
		
		SsrsPerformance totalPerformance = new SsrsPerformance();
		totalPerformance.setCyrs(cyrsCount);
		totalPerformance.setDepa("全院");
		totalPerformance.setOpsrs(count);
		totalPerformance.setPreCyrs(preCyrsCount);
		totalPerformance.setPreOpsrs(preCount);
		totalPerformance.setLastCyrs(lastCyrsCount);
		totalPerformance.setLastOpsrs(lastCount);
		totalPerformance.initDate();
		
		StringBuilder builder = new StringBuilder();
		builder.append(statisticalReportParam.getStatics1Name()).append("手术人数为").append(totalPerformance.getOpsrs()).append("人,")
		.append("比去年同期的").append(totalPerformance.getLastOpsrs()).append("人");
		if(totalPerformance.getOpsrs()!=null && totalPerformance.getLastOpsrs()!=null) {
			if(totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()>0) {
				builder.append("增加").append(totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()).append("人,增幅为")
				.append(totalPerformance.getRsTbzzLv()).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()<0) {
				builder.append("减少").append(totalPerformance.getLastOpsrs()-totalPerformance.getOpsrs()).append("人,减幅为")
				.append(totalPerformance.getRsTbzzLv()*-1).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()==0) {
				builder.append("相等;");
			}
		}
		builder.append("比上月的").append(totalPerformance.getPreOpsrs()).append("人");
		if(totalPerformance.getOpsrs()!=null && totalPerformance.getPreOpsrs()!=null) {
			if(totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()>0) {
				builder.append("增加").append(totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()).append("人,增幅为")
				.append(totalPerformance.getRsHbzzLv()).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()<0) {
				builder.append("减少").append(totalPerformance.getPreOpsrs()-totalPerformance.getOpsrs()).append("人,减幅为")
				.append(totalPerformance.getRsHbzzLv()*-1).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()==0) {
				builder.append("相等;");
			}
		}
		
		builder.append(statisticalReportParam.getStatics1Name()).append("手术占比为").append(totalPerformance.getOpsrsLv()).append("%,")
		.append("比去年同期的").append(totalPerformance.getLastOpsrsLv()).append("%");
		if(totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv()>0) {
			builder.append("增加").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv())).append("%,增幅为")
			.append(totalPerformance.getLvTbzzLv()).append("%;");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv()<0) {
			builder.append("减少").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getLastOpsrsLv()-totalPerformance.getOpsrsLv())).append("%,减幅为")
			.append(totalPerformance.getLvTbzzLv()*-1).append("%;");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv()==0) {
			builder.append("相等;");
		}
		
		
		builder.append("比上月的").append(totalPerformance.getPreOpsrsLv()).append("%");
		if(totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv()>0) {
			builder.append("增加").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv())).append("%,增幅为")
			.append(totalPerformance.getLvHbzzLv()).append("%。");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv()<0) {
			builder.append("减少").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getPreOpsrsLv()-totalPerformance.getOpsrsLv())).append("%,减幅为")
			.append(totalPerformance.getLvHbzzLv()*-1).append("%。");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv()==0) {
			builder.append("相等。");
		}
		
		builder.append("\n");
		
		
		Collections.sort(ssrsPerformanceList, new Comparator<SsrsPerformance>() {

			@Override
			public int compare(SsrsPerformance o1, SsrsPerformance o2) {
				if(o1 == null && o2 == null) {  
				    return 0;  
				}  
				if(o1 == null) {  
				    return 1;  
				}  
				if(o2 == null) {  
				    return -1;  
				}  
				if(o1.getOpsrs() == null) {  
				    return 1;  
				}  
				if(o2.getOpsrs() == null) {  
				    return -1;  
				}  
				
				return o2.getOpsrs().compareTo(o1.getOpsrs());
				
			}
		});
		
		int ssrsCount = 0;
		builder.append(statisticalReportParam.getStatics1Name()).append("手术人数最多的科室有");
		for (SsrsPerformance ssrsPerformance2 : ssrsPerformanceList) {
			if(ssrsCount==0) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==1) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==2) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==3) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==4) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）;");
			}
			ssrsCount++;
		}
		
		
		Collections.sort(ssrsPerformanceList, new Comparator<SsrsPerformance>() {

			@Override
			public int compare(SsrsPerformance o1, SsrsPerformance o2) {
				if(o1 == null && o2 == null) {  
				    return 0;  
				}  
				if(o1 == null) {  
				    return 1;  
				}  
				if(o2 == null) {  
				    return -1;  
				}  
				if(o1.getOpsrsLv() == null) {  
				    return 1;  
				}  
				if(o2.getOpsrsLv() == null) {  
				    return -1;  
				}  
				
				return o2.getOpsrsLv().compareTo(o1.getOpsrsLv());
			}
		});
		
		int ssrsLvCount = 0;
		builder.append(statisticalReportParam.getStatics1Name()).append("手术占比最高的科室为");
		for (SsrsPerformance ssrsPerformance2 : ssrsPerformanceList) {
			if(ssrsLvCount==0) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==1) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==2) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==3) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==4) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）。");
			}
			ssrsLvCount++;
		}
		
		builder.append("表13为"+statisticalReportParam.getStatics1Name()+"及去年同期和上月各手术科室手术人数及手术占比一览表。");
		
		System.out.println(builder.toString());
		
		ssrsPerformanceList.add(totalPerformance);
		
		performanceInfo.setNote(builder.toString());
		
		
		Collections.sort(ssrsPerformanceList, new Comparator<SsrsPerformance>() {

			@Override
			public int compare(SsrsPerformance o1, SsrsPerformance o2) {
				if(o1 == null && o2 == null) {  
				    return 0;  
				}  
				if(o1 == null) {  
				    return 1;  
				}  
				if(o2 == null) {  
				    return -1;  
				}  
				if(o1.getOpsrs() == null) {  
				    return 1;  
				}  
				if(o2.getOpsrs() == null) {  
				    return -1;  
				}  
				
				return o2.getOpsrs().compareTo(o1.getOpsrs());
			}
		});
		
		performanceInfo.setPerformanceList(ssrsPerformanceList);
		
		return performanceInfo;
		
		
		
	}
	
	public static CybingrenTJSearch generateCybingrenTJSearch(Date startDate,Date endDate,String deptCode) {
		CybingrenTJSearch cybingrenTJSearch = new CybingrenTJSearch();
		cybingrenTJSearch.setChuyuanrqStart(startDate);
		cybingrenTJSearch.setChuyuanrqEnd(endDate);
		if(StringUtils.isNotBlank(deptCode)) {
			cybingrenTJSearch.setCyks(deptCode);
		}
		return cybingrenTJSearch;
	}

	@Override
	public PerformanceInfo getSjssPerformance(StatisticalReportParam statisticalReportParam, String orgCode) {
		PerformanceInfo performanceInfo = new PerformanceInfo();
		
		Map<String,String> surgialDepas = Constant.SURGICAL_DEPARTMENT_MAP;
		
		
		SsrsPerformance ssrsPerformance = null;
		
		List<SsrsPerformance> ssrsPerformanceList = new ArrayList<>();
		
		for (Map.Entry<String, String> m : surgialDepas.entrySet()) {
			ssrsPerformance = new SsrsPerformance();
			String deptCode = m.getKey();
			String deptName = m.getValue();
			ssrsPerformance.setDepa(deptName);
			ssrsPerformance.setDepaCode(deptCode);
			
			String deptSql1 = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics1StartTime(),statisticalReportParam.getStatics1EndTime(),deptCode));
			Integer ssrsCount =tBaBaseMapper.getPerformanceData(deptSql1+performanceSql("sjrs"), orgCode);
			ssrsPerformance.setOpsrs(ssrsCount);
			Integer cyrsCount =  tBaBaseMapper.getPerformanceData(deptSql1+performanceSql("opsrs"), orgCode);
			ssrsPerformance.setCyrs(cyrsCount);
		
			String preDeptSql1 = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics2StartTime(),statisticalReportParam.getStatics2EndTime(),deptCode));
			Integer preSsrsCount = tBaBaseMapper.getPerformanceData(preDeptSql1+performanceSql("sjrs"), orgCode);
			ssrsPerformance.setPreOpsrs(preSsrsCount);
			Integer preCyrsCount = tBaBaseMapper.getPerformanceData(preDeptSql1+performanceSql("opsrs"), orgCode);
			ssrsPerformance.setPreCyrs(preCyrsCount);
			
			String lastDeptSql1 = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics3StartTime(),statisticalReportParam.getStatics3EndTime(),deptCode));
			Integer lastSsrsCount = tBaBaseMapper.getPerformanceData(lastDeptSql1+performanceSql("sjrs"), orgCode);
			ssrsPerformance.setLastOpsrs(lastSsrsCount);
			Integer lastCyrsCount = tBaBaseMapper.getPerformanceData(lastDeptSql1+performanceSql("opsrs"), orgCode);
			ssrsPerformance.setLastCyrs(lastCyrsCount);
			
			if(lastSsrsCount==null && preSsrsCount==null && ssrsCount==null) {
				continue;
			}
			
			ssrsPerformance.initDate();
			ssrsPerformanceList.add(ssrsPerformance);
		}
		

		String existsSql = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics1StartTime(),statisticalReportParam.getStatics1EndTime(),null));
		
		Integer count =tBaBaseMapper.getPerformanceData(existsSql+performanceSql("sjrs"), orgCode);
		Integer cyrsCount =tBaBaseMapper.getPerformanceData(existsSql+performanceSql("opsrs"), orgCode);
		
		String preTotalSql = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics2StartTime(),statisticalReportParam.getStatics2EndTime(),null));
		Integer preCount = tBaBaseMapper.getPerformanceData(preTotalSql+performanceSql("sjrs"), orgCode);
		Integer preCyrsCount = tBaBaseMapper.getPerformanceData(preTotalSql+performanceSql("opsrs"), orgCode);
		
		String lastTotalSql = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics3StartTime(),statisticalReportParam.getStatics3EndTime(),null));
		Integer lastCount = tBaBaseMapper.getPerformanceData(lastTotalSql+performanceSql("sjrs"), orgCode);
		Integer lastCyrsCount = tBaBaseMapper.getPerformanceData(lastTotalSql+performanceSql("opsrs"), orgCode);
		
		SsrsPerformance totalPerformance = new SsrsPerformance();
		totalPerformance.setCyrs(cyrsCount);
		totalPerformance.setDepa("全院");
		totalPerformance.setOpsrs(count);
		totalPerformance.setPreCyrs(preCyrsCount);
		totalPerformance.setPreOpsrs(preCount);
		totalPerformance.setLastCyrs(lastCyrsCount);
		totalPerformance.setLastOpsrs(lastCount);
		totalPerformance.initDate();
		
		StringBuilder builder = new StringBuilder();
		builder.append(statisticalReportParam.getStatics1Name()).append("四级手术人数为").append(totalPerformance.getOpsrs()).append("人,")
		.append("比去年同期的").append(totalPerformance.getLastOpsrs()).append("人");
		if(totalPerformance.getOpsrs()!=null && totalPerformance.getLastOpsrs()!=null) {
			if(totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()>0) {
				builder.append("增加").append(totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()).append("人,增幅为")
				.append(totalPerformance.getRsTbzzLv()).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()<0) {
				builder.append("减少").append(totalPerformance.getLastOpsrs()-totalPerformance.getOpsrs()).append("人,减幅为")
				.append(totalPerformance.getRsTbzzLv()*-1).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()==0) {
				builder.append("相等;");
			}
		}
		builder.append("比上月的").append(totalPerformance.getPreOpsrs()).append("人");
		if(totalPerformance.getOpsrs()!=null && totalPerformance.getPreOpsrs()!=null) {
			if(totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()>0) {
				builder.append("增加").append(totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()).append("人,增幅为")
				.append(totalPerformance.getRsHbzzLv()).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()<0) {
				builder.append("减少").append(totalPerformance.getPreOpsrs()-totalPerformance.getOpsrs()).append("人,减幅为")
				.append(totalPerformance.getRsHbzzLv()*-1).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()==0) {
				builder.append("相等;");
			}
		}
		
		builder.append(statisticalReportParam.getStatics1Name()).append("四级手术占比为").append(totalPerformance.getOpsrsLv()).append("%,")
		.append("比去年同期的").append(totalPerformance.getLastOpsrsLv()).append("%");
		if(totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv()>0) {
			builder.append("增加").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv())).append("%,增幅为")
			.append(totalPerformance.getLvTbzzLv()).append("%;");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv()<0) {
			builder.append("减少").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getLastOpsrsLv()-totalPerformance.getOpsrsLv())).append("%,减幅为")
			.append(totalPerformance.getLvTbzzLv()*-1).append("%;");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv()==0) {
			builder.append("相等;");
		}
		
		
		builder.append("比上月的").append(totalPerformance.getPreOpsrsLv()).append("%");
		if(totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv()>0) {
			builder.append("增加").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv())).append("%,增幅为")
			.append(totalPerformance.getLvHbzzLv()).append("%。");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv()<0) {
			builder.append("减少").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getPreOpsrsLv()-totalPerformance.getOpsrsLv())).append("%,减幅为")
			.append(totalPerformance.getLvHbzzLv()*-1).append("%。");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv()==0) {
			builder.append("相等。");
		}
		
		builder.append("\n");
	
		
		Collections.sort(ssrsPerformanceList, new Comparator<SsrsPerformance>() {
			@Override
			public int compare(SsrsPerformance o1, SsrsPerformance o2) {
				if(o1 == null && o2 == null) {  
				    return 0;  
				}  
				if(o1 == null) {  
				    return 1;  
				}  
				if(o2 == null) {  
				    return -1;  
				}  
				if(o1.getOpsrs() == null) {  
				    return 1;  
				}  
				if(o2.getOpsrs() == null) {  
				    return -1;  
				}  
				
				return o2.getOpsrs().compareTo(o1.getOpsrs());
			}
		});
		
		int ssrsCount = 0;
		builder.append(statisticalReportParam.getStatics1Name()).append("四级手术人数最多的科室有");
		for (SsrsPerformance ssrsPerformance2 : ssrsPerformanceList) {
			if(ssrsCount==0) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==1) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==2) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==3) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==4) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）;");
			}
			ssrsCount++;
		}
	
		
		Collections.sort(ssrsPerformanceList, new Comparator<SsrsPerformance>() {

			@Override
			public int compare(SsrsPerformance o1, SsrsPerformance o2) {
				if(o1 == null && o2 == null) {  
				    return 0;  
				}  
				if(o1 == null) {  
				    return 1;  
				}  
				if(o2 == null) {  
				    return -1;  
				}  
				if(o1.getOpsrsLv() == null) {  
				    return 1;  
				}  
				if(o2.getOpsrsLv() == null) {  
				    return -1;  
				}  
				
				return o2.getOpsrsLv().compareTo(o1.getOpsrsLv());
			}
		});
		
		int ssrsLvCount = 0;
		builder.append(statisticalReportParam.getStatics1Name()).append("四级手术占比最高的科室为");
		for (SsrsPerformance ssrsPerformance2 : ssrsPerformanceList) {
			if(ssrsLvCount==0) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==1) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==2) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==3) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==4) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）。");
			}
			ssrsLvCount++;
		}
		
		builder.append("表14为"+statisticalReportParam.getStatics1Name()+"及去年同期和上月各手术科室四级手术人数及手术占比一览表。");
		
		System.out.println(builder.toString());
		
		
		ssrsPerformanceList.add(totalPerformance);
		
		performanceInfo.setNote(builder.toString());
		
		Collections.sort(ssrsPerformanceList, new Comparator<SsrsPerformance>() {

			@Override
			public int compare(SsrsPerformance o1, SsrsPerformance o2) {
				if(o1 == null && o2 == null) {  
				    return 0;  
				}  
				if(o1 == null) {  
				    return 1;  
				}  
				if(o2 == null) {  
				    return -1;  
				}  
				if(o1.getOpsrs() == null) {  
				    return 1;  
				}  
				if(o2.getOpsrs() == null) {  
				    return -1;  
				}  
				
				return o2.getOpsrs().compareTo(o1.getOpsrs());
				
			}
		});
		
		performanceInfo.setPerformanceList(ssrsPerformanceList);
		
		return performanceInfo;
	}

	@Override
	public PerformanceInfo getminiPerformance(StatisticalReportParam statisticalReportParam, String orgCode) {
	PerformanceInfo performanceInfo = new PerformanceInfo();
		
		Map<String,String> surgialDepas = Constant.SURGICAL_DEPARTMENT_MAP;
		
		
		SsrsPerformance ssrsPerformance = null;
		
		List<SsrsPerformance> ssrsPerformanceList = new ArrayList<>();
		
		for (Map.Entry<String, String> m : surgialDepas.entrySet()) {
			ssrsPerformance = new SsrsPerformance();
			String deptCode = m.getKey();
			String deptName = m.getValue();
			ssrsPerformance.setDepa(deptName);
			ssrsPerformance.setDepaCode(deptCode);
			
			String deptSql1 = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics1StartTime(),statisticalReportParam.getStatics1EndTime(),deptCode));
			Integer ssrsCount =tBaBaseMapper.getPerformanceData(deptSql1+performanceSql("mini"), orgCode);
			ssrsPerformance.setOpsrs(ssrsCount);
			Integer cyrsCount =  tBaBaseMapper.getPerformanceData(deptSql1+performanceSql("opsrs"), orgCode);
			ssrsPerformance.setCyrs(cyrsCount);
		
			String preDeptSql1 = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics2StartTime(),statisticalReportParam.getStatics2EndTime(),deptCode));
			Integer preSsrsCount = tBaBaseMapper.getPerformanceData(preDeptSql1+performanceSql("mini"), orgCode);
			ssrsPerformance.setPreOpsrs(preSsrsCount);
			Integer preCyrsCount = tBaBaseMapper.getPerformanceData(preDeptSql1+performanceSql("opsrs"), orgCode);
			ssrsPerformance.setPreCyrs(preCyrsCount);
			
			String lastDeptSql1 = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics3StartTime(),statisticalReportParam.getStatics3EndTime(),deptCode));
			Integer lastSsrsCount = tBaBaseMapper.getPerformanceData(lastDeptSql1+performanceSql("mini"), orgCode);
			ssrsPerformance.setLastOpsrs(lastSsrsCount);
			Integer lastCyrsCount = tBaBaseMapper.getPerformanceData(lastDeptSql1+performanceSql("opsrs"), orgCode);
			ssrsPerformance.setLastCyrs(lastCyrsCount);
			
			
			ssrsPerformance.initDate();
			if(ssrsPerformance.getOpsrs()==null || ssrsPerformance.getPreOpsrs()==null || ssrsPerformance.getLastOpsrs()==null) {
				continue;
			}
			ssrsPerformanceList.add(ssrsPerformance);
		}
		

		String existsSql = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics1StartTime(),statisticalReportParam.getStatics1EndTime(),null));
		
		Integer count =tBaBaseMapper.getPerformanceData(existsSql+performanceSql("mini"), orgCode);
		Integer cyrsCount =tBaBaseMapper.getPerformanceData(existsSql+performanceSql("opsrs"), orgCode);
		
		String preTotalSql = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics2StartTime(),statisticalReportParam.getStatics2EndTime(),null));
		Integer preCount = tBaBaseMapper.getPerformanceData(preTotalSql+performanceSql("mini"), orgCode);
		Integer preCyrsCount = tBaBaseMapper.getPerformanceData(preTotalSql+performanceSql("opsrs"), orgCode);
		
		String lastTotalSql = TongJiSaqlUtil.disFeiyong(orgCode, generateCybingrenTJSearch(statisticalReportParam.getStatics3StartTime(),statisticalReportParam.getStatics3EndTime(),null));
		Integer lastCount = tBaBaseMapper.getPerformanceData(lastTotalSql+performanceSql("mini"), orgCode);
		Integer lastCyrsCount = tBaBaseMapper.getPerformanceData(lastTotalSql+performanceSql("opsrs"), orgCode);
		
		SsrsPerformance totalPerformance = new SsrsPerformance();
		totalPerformance.setCyrs(cyrsCount);
		totalPerformance.setDepa("全院");
		totalPerformance.setOpsrs(count);
		totalPerformance.setPreCyrs(preCyrsCount);
		totalPerformance.setPreOpsrs(preCount);
		totalPerformance.setLastCyrs(lastCyrsCount);
		totalPerformance.setLastOpsrs(lastCount);
		totalPerformance.initDate();
		
		StringBuilder builder = new StringBuilder();
		builder.append(statisticalReportParam.getStatics1Name()).append("微创手术人数为").append(totalPerformance.getOpsrs()).append("人,")
		.append("比去年同期的").append(totalPerformance.getLastOpsrs()).append("人");
		if(totalPerformance.getOpsrs()!=null && totalPerformance.getLastOpsrs()!=null) {
			if(totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()>0) {
				builder.append("增加").append(totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()).append("人,增幅为")
				.append(totalPerformance.getRsTbzzLv()).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()<0) {
				builder.append("减少").append(totalPerformance.getLastOpsrs()-totalPerformance.getOpsrs()).append("人,减幅为")
				.append(totalPerformance.getRsTbzzLv()*-1).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getLastOpsrs()==0) {
				builder.append("相等;");
			}
		}
		builder.append("比上月的").append(totalPerformance.getPreOpsrs()).append("人");
		if(totalPerformance.getOpsrs()!=null && totalPerformance.getPreOpsrs()!=null) {
			if(totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()>0) {
				builder.append("增加").append(totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()).append("人,增幅为")
				.append(totalPerformance.getRsHbzzLv()).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()<0) {
				builder.append("减少").append(totalPerformance.getPreOpsrs()-totalPerformance.getOpsrs()).append("人,减幅为")
				.append(totalPerformance.getRsHbzzLv()*-1).append("%;");
			}else if (totalPerformance.getOpsrs()-totalPerformance.getPreOpsrs()==0) {
				builder.append("相等;");
			}
		}
		
		builder.append(statisticalReportParam.getStatics1Name()).append("微创手术占比为").append(totalPerformance.getOpsrsLv()).append("%,")
		.append("比去年同期的").append(totalPerformance.getLastOpsrsLv()).append("%");
		if(totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv()>0) {
			builder.append("增加").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv())).append("%,增幅为")
			.append(totalPerformance.getLvTbzzLv()).append("%;");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv()<0) {
			builder.append("减少").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getLastOpsrsLv()-totalPerformance.getOpsrsLv())).append("%,减幅为")
			.append(totalPerformance.getLvTbzzLv()*-1).append("%;");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getLastOpsrsLv()==0) {
			builder.append("相等;");
		}
		
		
		builder.append("比上月的").append(totalPerformance.getPreOpsrsLv()).append("%");
		if(totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv()>0) {
			builder.append("增加").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv())).append("%,增幅为")
			.append(totalPerformance.getLvHbzzLv()).append("%。");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv()<0) {
			builder.append("减少").append(NumberUtil.getLiangweiXiaoShu(totalPerformance.getPreOpsrsLv()-totalPerformance.getOpsrsLv())).append("%,减幅为")
			.append(totalPerformance.getLvHbzzLv()*-1).append("%。");
		}else if (totalPerformance.getOpsrsLv()-totalPerformance.getPreOpsrsLv()==0) {
			builder.append("相等。");
		}
		
		builder.append("\n");
	
		
		
		Collections.sort(ssrsPerformanceList, new Comparator<SsrsPerformance>() {

			@Override
			public int compare(SsrsPerformance o1, SsrsPerformance o2) {
				if(o1 == null && o2 == null) {  
				    return 0;  
				}  
				if(o1 == null) {  
				    return 1;  
				}  
				if(o2 == null) {  
				    return -1;  
				}  
				if(o1.getOpsrs() == null) {  
				    return 1;  
				}  
				if(o2.getOpsrs() == null) {  
				    return -1;  
				}  
				
				return o2.getOpsrs().compareTo(o1.getOpsrs());
			}
		});
		
		int ssrsCount = 0;
		builder.append(statisticalReportParam.getStatics1Name()).append("微创手术人数最多的科室有");
		for (SsrsPerformance ssrsPerformance2 : ssrsPerformanceList) {
			if(ssrsCount==0) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==1) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==2) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==3) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）、");
			}else if(ssrsCount==4) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrs()).append("人）;");
			}
			ssrsCount++;
		}
		
		
		Collections.sort(ssrsPerformanceList, new Comparator<SsrsPerformance>() {

			@Override
			public int compare(SsrsPerformance o1, SsrsPerformance o2) {
				if(o1 == null && o2 == null) {  
				    return 0;  
				}  
				if(o1 == null) {  
				    return 1;  
				}  
				if(o2 == null) {  
				    return -1;  
				}  
				if(o1.getOpsrsLv() == null) {  
				    return 1;  
				}  
				if(o2.getOpsrsLv() == null) {  
				    return -1;  
				}  
				
				return o2.getOpsrsLv().compareTo(o1.getOpsrsLv());
			}
		});
		
		int ssrsLvCount = 0;
		builder.append(statisticalReportParam.getStatics1Name()).append("微创手术占比最高的科室为");
		for (SsrsPerformance ssrsPerformance2 : ssrsPerformanceList) {
			if(ssrsLvCount==0) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==1) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==2) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==3) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）、");
			}else if(ssrsLvCount==4) {
				builder.append(ssrsPerformance2.getDepa()).append("（").append(ssrsPerformance2.getOpsrsLv()).append("%）。");
			}
			ssrsLvCount++;
		}
		
		builder.append("表15为"+statisticalReportParam.getStatics1Name()+"及去年同期和上月各手术科室微创手术人数及微创手术占比一览表。");
		
		System.out.println(builder.toString());
		
		ssrsPerformanceList.add(totalPerformance);
		performanceInfo.setNote(builder.toString());
		
		Collections.sort(ssrsPerformanceList, new Comparator<SsrsPerformance>() {

			@Override
			public int compare(SsrsPerformance o1, SsrsPerformance o2) {
				if(o1 == null && o2 == null) {  
				    return 0;  
				}  
				if(o1 == null) {  
				    return 1;  
				}  
				if(o2 == null) {  
				    return -1;  
				}  
				if(o1.getOpsrs() == null) {  
				    return 1;  
				}  
				if(o2.getOpsrs() == null) {  
				    return -1;  
				}  
				
				return o2.getOpsrs().compareTo(o1.getOpsrs());
				
			}
		});
		
		performanceInfo.setPerformanceList(ssrsPerformanceList);
		
		return performanceInfo;
	}
	
	
	@Override
	public SingleDiagQcInfo getSingleDiagQcInfo(StatisticalReportParam statisticalReportParam, String orgCode) {
		SingleDiagQcInfo singleDiagQcInfo = new SingleDiagQcInfo(); 
		
		
		List<SingleDiagQcRecord> diagSingleDiagQcRecords = this.getSingleDiagQcRecords(statisticalReportParam, orgCode, "2");
		if(CollectionUtils.isNotEmpty(diagSingleDiagQcRecords)) {
			singleDiagQcInfo.getSingleDiagQcRecords().addAll(diagSingleDiagQcRecords);
		}
		
		List<SingleDiagQcRecord> opSingleDiagQcRecords = this.getSingleDiagQcRecords(statisticalReportParam, orgCode, "3");
		if(CollectionUtils.isNotEmpty(opSingleDiagQcRecords)) {
			singleDiagQcInfo.getSingleDiagQcRecords().addAll(opSingleDiagQcRecords);
		}
		
		
		
		return singleDiagQcInfo;
	}
	
	
	public List<SingleDiagQcRecord> getSingleDiagQcRecords(StatisticalReportParam statisticalReportParam,String orgCode,String code){
		List<StdQcIndex> stdQcIndexList = new LinkedList<StdQcIndex>();
		List<SingleDiagQcRecord> linkedList = new LinkedList<>();
		try {
			Map<String, String> params = new HashMap<>();
			params.put("code", code);
			String json = HttpClientUtil.doPost("http://11.0.0.55:8999/medicalQuality/getStdQcIndexByCode", params);
			stdQcIndexList = JsonUtil.jsonToList(json, StdQcIndex.class);
			System.out.println("原始单病种字典数据总数:"+stdQcIndexList.size());
			SingleDiagQcRecord singleDiagQcRecord = null;
			for (StdQcIndex stdQcIndex : stdQcIndexList) {
				if(stdQcIndex.getName().contains("绩效")) {
					MedicalQuality medicalQuality = this.getMedicalQuality(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()), orgCode, code, stdQcIndex.getId().toString());
					MedicalQuality preMedicalQuality = this.getMedicalQuality(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()), orgCode, code, stdQcIndex.getId().toString());
					MedicalQuality lastMedicalQuality = this.getMedicalQuality(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()), orgCode, code, stdQcIndex.getId().toString());
					
					singleDiagQcRecord = new SingleDiagQcRecord();
					singleDiagQcRecord.setTypeName(stdQcIndex.getName().replace("（绩效）", ""));
					if(medicalQuality!=null) {
						if("2".equals(code)) {
							singleDiagQcRecord.setOutNum(medicalQuality.getDischarges());
							singleDiagQcRecord.setDeathNum(medicalQuality.getDeaths());
							if(medicalQuality.getDeaths()!=null && medicalQuality.getDischarges()!=null && medicalQuality.getDeaths()>0) {
								singleDiagQcRecord.setDeathLv(NumberUtil.getBaiFenNumber(medicalQuality.getDeaths() * 1.0 / medicalQuality.getDischarges()));
							}else {
								singleDiagQcRecord.setDeathLv(0D);
							}
						}else if("3".equals(code)) {
							singleDiagQcRecord.setOutNum(medicalQuality.getSurgicalN());
							singleDiagQcRecord.setDeathNum(medicalQuality.getDeathSurgicalN());
							if(medicalQuality.getDeathSurgicalN()!=null && medicalQuality.getSurgicalN()!=null && medicalQuality.getDeathSurgicalN()>0) {
								singleDiagQcRecord.setDeathLv(NumberUtil.getBaiFenNumber(medicalQuality.getDeathSurgicalN() * 1.0 / medicalQuality.getSurgicalN()));
							}else {
								singleDiagQcRecord.setDeathLv(0D);
							}
						}
						
						singleDiagQcRecord.setAvgDays(medicalQuality.getAverageStay());
						singleDiagQcRecord.setAvgFee(medicalQuality.getCostPer());
						
					}
					
					if(preMedicalQuality!=null) {
						if("2".equals(code)) {
							singleDiagQcRecord.setPreOutNum(preMedicalQuality.getDischarges());
							singleDiagQcRecord.setPreDeathNum(preMedicalQuality.getDeaths());
							if(preMedicalQuality.getDeaths()!=null && preMedicalQuality.getDischarges()!=null && preMedicalQuality.getDeaths()>0) {
								singleDiagQcRecord.setPreDeathLv(NumberUtil.getBaiFenNumber(preMedicalQuality.getDeaths() * 1.0 / preMedicalQuality.getDischarges()));
							}else {
								singleDiagQcRecord.setPreDeathLv(0D);
							}
						}else if("3".equals(code)) {
							singleDiagQcRecord.setPreOutNum(preMedicalQuality.getSurgicalN());
							singleDiagQcRecord.setPreDeathNum(preMedicalQuality.getDeathSurgicalN());
							if(preMedicalQuality.getDeathSurgicalN()!=null && preMedicalQuality.getSurgicalN()!=null && preMedicalQuality.getDeathSurgicalN()>0) {
								singleDiagQcRecord.setPreDeathLv(NumberUtil.getBaiFenNumber(preMedicalQuality.getDeathSurgicalN() * 1.0 / preMedicalQuality.getSurgicalN()));
							}else {
								singleDiagQcRecord.setPreDeathLv(0D);
							}
						}
						
						singleDiagQcRecord.setPreAvgDays(preMedicalQuality.getAverageStay());
						singleDiagQcRecord.setPreAvgFee(preMedicalQuality.getCostPer());
						
					}
					
					if(lastMedicalQuality!=null) {
						if("2".equals(code)) {
							singleDiagQcRecord.setLastYearOutNum(lastMedicalQuality.getDischarges());
							singleDiagQcRecord.setLastYearDeathNum(lastMedicalQuality.getDeaths());
							if(lastMedicalQuality.getDeaths()!=null && lastMedicalQuality.getDischarges()!=null && lastMedicalQuality.getDeaths()>0) {
								singleDiagQcRecord.setLastYearDeathLv(NumberUtil.getBaiFenNumber(lastMedicalQuality.getDeaths() * 1.0 / lastMedicalQuality.getDischarges()));
							}else {
								singleDiagQcRecord.setLastYearDeathLv(0D);
							}
						}else if("3".equals(code)) {
							singleDiagQcRecord.setLastYearOutNum(lastMedicalQuality.getSurgicalN());
							singleDiagQcRecord.setLastYearDeathNum(lastMedicalQuality.getDeathSurgicalN());
							if(lastMedicalQuality.getDeathSurgicalN()!=null && lastMedicalQuality.getSurgicalN()!=null && lastMedicalQuality.getDeathSurgicalN()>0) {
								singleDiagQcRecord.setLastYearDeathLv(NumberUtil.getBaiFenNumber(lastMedicalQuality.getDeathSurgicalN() * 1.0 / lastMedicalQuality.getSurgicalN()));
							}else {
								singleDiagQcRecord.setLastYearDeathLv(0D);
							}
						}
						
						singleDiagQcRecord.setLastYearAvgDays(lastMedicalQuality.getAverageStay());
						singleDiagQcRecord.setLastYearAvgFee(lastMedicalQuality.getCostPer());
					
					}
					
					linkedList.add(singleDiagQcRecord);
					
				
				}
			}
			
		}catch(Exception e) {
			e.printStackTrace();
		}
		return linkedList;
	}

	@Override
	public OutPatientZtqkInfo getOutPatientZtqkInfo(StatisticalReportParam statisticalReportParam) {
		OutPatientZtqkInfo outPatientZtqkInfo = new OutPatientZtqkInfo();
		try {
		//门急诊
		String[] medicalClassArr = {"1","11","12","121","122","123","13","2","21"};
		//门诊
		String[] medicalClassMzArr = {"1","11","12","121","122","123","13"};
		//急诊
		String[] medicalClassZjMzArr = {"2","21"};
		
		int nowMonthMjzNum = getOutPatientNum(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),Arrays.asList(medicalClassArr),statisticalReportParam.getOrganizationId());
		
		int preMonthMjzNum = getOutPatientNum(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),Arrays.asList(medicalClassArr),statisticalReportParam.getOrganizationId());
		
		int lastMonthMjzNum = getOutPatientNum(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),Arrays.asList(medicalClassArr),statisticalReportParam.getOrganizationId());
		
		
		int nowMonthMzNum = getOutPatientNum(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),Arrays.asList(medicalClassMzArr),statisticalReportParam.getOrganizationId());
		
		int preMonthMzNum = getOutPatientNum(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),Arrays.asList(medicalClassMzArr),statisticalReportParam.getOrganizationId());
		
		int lastMonthMzNum = getOutPatientNum(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),Arrays.asList(medicalClassMzArr),statisticalReportParam.getOrganizationId());
		
		
		int nowMonthJzNum = getOutPatientNum(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),Arrays.asList(medicalClassZjMzArr),statisticalReportParam.getOrganizationId());
		
		int preMonthJzNum = getOutPatientNum(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),Arrays.asList(medicalClassZjMzArr),statisticalReportParam.getOrganizationId());
		
		int lastMonthJzNum = getOutPatientNum(DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.DateToStr("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),Arrays.asList(medicalClassZjMzArr),statisticalReportParam.getOrganizationId());
		
		
		
		StringBuilder builder = new StringBuilder();
		builder.append(statisticalReportParam.getStatics1Name()).append("门急诊量为").append(nowMonthMjzNum).append("人次，比")
		.append(statisticalReportParam.getStatics3Name()).append(lastMonthMjzNum).append("人次").append(BigDecimalUtil.getCompareResult(new BigDecimal(nowMonthMjzNum),new BigDecimal(lastMonthMjzNum)))
		.append(BigDecimalUtil.getNumDifference(new BigDecimal(nowMonthMjzNum),new BigDecimal(lastMonthMjzNum))).append("人次，")
		.append(BigDecimalUtil.getCompareRateResult(new BigDecimal(nowMonthMjzNum),new BigDecimal(lastMonthMjzNum)))
		.append(BigDecimalUtil.getCompareRate(new BigDecimal(nowMonthMjzNum),new BigDecimal(lastMonthMjzNum))).append("%,比")
		.append(statisticalReportParam.getStatics2Name()).append(preMonthMjzNum).append("人次，").append(BigDecimalUtil.getCompareResult(new BigDecimal(nowMonthMjzNum),new BigDecimal(preMonthMjzNum)))
		.append(BigDecimalUtil.getNumDifference(new BigDecimal(nowMonthMjzNum),new BigDecimal(preMonthMjzNum))).append("人次，")
		.append(BigDecimalUtil.getCompareRateResult(new BigDecimal(nowMonthMjzNum),new BigDecimal(preMonthMjzNum)))
		.append(BigDecimalUtil.getCompareRate(new BigDecimal(nowMonthMjzNum),new BigDecimal(lastMonthMjzNum))).append("%。\n");
		
		
		builder.append(    statisticalReportParam.getStatics1Name()).append("门诊量为").append(nowMonthMzNum).append("人次，比")
		.append(statisticalReportParam.getStatics3Name()).append(lastMonthMzNum).append("人次").append(BigDecimalUtil.getCompareResult(new BigDecimal(nowMonthMzNum),new BigDecimal(lastMonthMzNum)))
		.append(BigDecimalUtil.getNumDifference(new BigDecimal(nowMonthMzNum),new BigDecimal(lastMonthMzNum))).append("人次，")
		.append(BigDecimalUtil.getCompareRateResult(new BigDecimal(nowMonthMzNum),new BigDecimal(lastMonthMzNum)))
		.append(BigDecimalUtil.getCompareRate(new BigDecimal(nowMonthMzNum),new BigDecimal(lastMonthMzNum))).append("%,比")
		.append(statisticalReportParam.getStatics2Name()).append(preMonthMzNum).append("人次，").append(BigDecimalUtil.getCompareResult(new BigDecimal(nowMonthMzNum),new BigDecimal(preMonthMzNum)))
		.append(BigDecimalUtil.getNumDifference(new BigDecimal(nowMonthMzNum),new BigDecimal(preMonthMzNum))).append("人次，")
		.append(BigDecimalUtil.getCompareRateResult(new BigDecimal(nowMonthMzNum),new BigDecimal(preMonthMzNum)))
		.append(BigDecimalUtil.getCompareRate(new BigDecimal(nowMonthMzNum),new BigDecimal(preMonthMzNum))).append("%。\n");
		
		
		 builder.append(    statisticalReportParam.getStatics1Name()).append("急诊量为").append(nowMonthJzNum).append("人次，比")
		.append(statisticalReportParam.getStatics3Name()).append(lastMonthJzNum).append("人次").append(BigDecimalUtil.getCompareResult(new BigDecimal(nowMonthJzNum),new BigDecimal(lastMonthJzNum)))
		.append(BigDecimalUtil.getNumDifference(new BigDecimal(nowMonthJzNum),new BigDecimal(lastMonthJzNum))).append("人次，")
		.append(BigDecimalUtil.getCompareRateResult(new BigDecimal(nowMonthJzNum),new BigDecimal(lastMonthJzNum)))
		.append(BigDecimalUtil.getCompareRate(new BigDecimal(nowMonthJzNum),new BigDecimal(lastMonthJzNum))).append("%,比")
		.append(statisticalReportParam.getStatics2Name()).append(preMonthJzNum).append("人次，").append(BigDecimalUtil.getCompareResult(new BigDecimal(nowMonthJzNum),new BigDecimal(preMonthJzNum)))
		.append(BigDecimalUtil.getNumDifference(new BigDecimal(nowMonthJzNum),new BigDecimal(preMonthJzNum))).append("人次，")
		.append(BigDecimalUtil.getCompareRateResult(new BigDecimal(nowMonthMzNum),new BigDecimal(preMonthJzNum)))
		.append(BigDecimalUtil.getCompareRate(new BigDecimal(nowMonthJzNum),new BigDecimal(preMonthJzNum))).append("%。");
		
		outPatientZtqkInfo.setNote(builder.toString());
		
		List<String> monthList = new ArrayList<>();
		monthList.add(statisticalReportParam.getStatics1Name());
		monthList.add(statisticalReportParam.getStatics3Name());
		monthList.add(statisticalReportParam.getStatics2Name());
		
		outPatientZtqkInfo.setMonthList(monthList);
		
		List<Integer> param1List = new LinkedList<>();
		param1List.add(nowMonthMjzNum);
		param1List.add(nowMonthMzNum);
		param1List.add(nowMonthJzNum);
		
		outPatientZtqkInfo.setParam1List(param1List);
		
		
		List<Integer> param2List = new LinkedList<>();
		param2List.add(lastMonthMjzNum);
		param2List.add(lastMonthMzNum);
		param2List.add(lastMonthJzNum);
		
		outPatientZtqkInfo.setParam2List(param2List);
		
		List<Integer> param3List = new LinkedList<>();
		param3List.add(preMonthMjzNum);
		param3List.add(preMonthMzNum);
		param3List.add(preMonthJzNum);
		
		outPatientZtqkInfo.setParam3List(param3List);
		
		
		//2020年8月门急诊量为？人次，比2019年8月的？人次减少/增加？人次，减幅/增幅为？%，比2020年7月的？人次减少/增加？人次，减幅/增幅为？%。
		
		System.out.println(builder.toString());
		
		
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
		
		return outPatientZtqkInfo;
	}
	
	
	/**
	 * 查询门诊患者信息数量
	 * @param startTime
	 * @param endTime
	 * @param medicalClassList
	 * @return
	 */
	public int getOutPatientNum(String startTime,String endTime,List<String> medicalClassList,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setMedicalClassList(medicalClassList);
		outPatientParam.setOrgCode(orgCode);
		return mrInBasicMapper.getOutPatientNumByInTime(outPatientParam);
	}

	
	
	@Override
	public OutPatientJzyslxInfo getOutPatientJzyslxInfo(StatisticalReportParam statisticalReportParam) {
		OutpatientJzyslx record = getOutPatientJzyslxRecord(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),statisticalReportParam.getOrganizationId());
		OutpatientJzyslx preMonthRecord = getOutPatientJzyslxRecord(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),statisticalReportParam.getOrganizationId());
		OutpatientJzyslx lastYearRecord = getOutPatientJzyslxRecord(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),statisticalReportParam.getOrganizationId());
		
		
		OutPatientJzyslxInfo outPatientJzyslxInfo = new OutPatientJzyslxInfo();
		
		System.out.println(record);
		System.out.println(preMonthRecord);
		System.out.println(lastYearRecord);

		String note = 
		"    "+statisticalReportParam.getStatics1Name()+"全院专家门诊共接诊患者"+record.getZjmzCount()+"人次，比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getZjmzCount()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getZjmzCount()), new BigDecimal(lastYearRecord.getZjmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getZjmzCount()), new BigDecimal(lastYearRecord.getZjmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getZjmzCount()), new BigDecimal(lastYearRecord.getZjmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getZjmzCount()), new BigDecimal(lastYearRecord.getZjmzCount()))+"%，比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getZjmzCount()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getZjmzCount()), new BigDecimal(preMonthRecord.getZjmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getZjmzCount()), new BigDecimal(preMonthRecord.getZjmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getZjmzCount()), new BigDecimal(preMonthRecord.getZjmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getZjmzCount()), new BigDecimal(preMonthRecord.getZjmzCount()))+"%。\n"+
		"    其中，知名专家门诊共接诊"+record.getZmzjmzCount()+"人次，比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getZmzjmzCount()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getZmzjmzCount()), new BigDecimal(lastYearRecord.getZmzjmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getZmzjmzCount()), new BigDecimal(lastYearRecord.getZmzjmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getZmzjmzCount()), new BigDecimal(lastYearRecord.getZmzjmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getZmzjmzCount()), new BigDecimal(lastYearRecord.getZmzjmzCount()))+"%，比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getZmzjmzCount()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getZmzjmzCount()), new BigDecimal(preMonthRecord.getZmzjmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getZmzjmzCount()), new BigDecimal(preMonthRecord.getZmzjmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getZmzjmzCount()), new BigDecimal(preMonthRecord.getZmzjmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getZmzjmzCount()), new BigDecimal(preMonthRecord.getZmzjmzCount()))+"%。\n"+
		"    主任医师接诊"+record.getZrysmzCount()+"人次，比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getZrysmzCount()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getZrysmzCount()), new BigDecimal(lastYearRecord.getZrysmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getZrysmzCount()), new BigDecimal(lastYearRecord.getZrysmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getZrysmzCount()), new BigDecimal(lastYearRecord.getZrysmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getZrysmzCount()), new BigDecimal(lastYearRecord.getZrysmzCount()))+"%，比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getZrysmzCount()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getZrysmzCount()), new BigDecimal(preMonthRecord.getZrysmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getZrysmzCount()), new BigDecimal(preMonthRecord.getZrysmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getZrysmzCount()), new BigDecimal(preMonthRecord.getZrysmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getZrysmzCount()), new BigDecimal(preMonthRecord.getZrysmzCount()))+"%。\n"+
		"    副主任医师接诊"+record.getFzrysmzCount()+"人次，比"+statisticalReportParam.getStatics3Name()+"的？人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getFzrysmzCount()), new BigDecimal(lastYearRecord.getFzrysmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getFzrysmzCount()), new BigDecimal(lastYearRecord.getFzrysmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getFzrysmzCount()), new BigDecimal(lastYearRecord.getFzrysmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getFzrysmzCount()), new BigDecimal(lastYearRecord.getFzrysmzCount()))+"%，比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getFzrysmzCount()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getFzrysmzCount()), new BigDecimal(preMonthRecord.getFzrysmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getFzrysmzCount()), new BigDecimal(preMonthRecord.getFzrysmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getFzrysmzCount()), new BigDecimal(preMonthRecord.getFzrysmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getFzrysmzCount()), new BigDecimal(preMonthRecord.getFzrysmzCount()))+"%。\n"+
		"    普通门诊（包括专业学科普通门诊、院外门诊、门规门诊、干部保健、医保门诊、便民门诊）接诊患者"+record.getPtmzCount()+"人次，比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getPtmzCount()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getPtmzCount()), new BigDecimal(lastYearRecord.getPtmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getPtmzCount()), new BigDecimal(lastYearRecord.getPtmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getPtmzCount()), new BigDecimal(lastYearRecord.getPtmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getPtmzCount()), new BigDecimal(lastYearRecord.getPtmzCount()))+"%，比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getPtmzCount()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getPtmzCount()), new BigDecimal(preMonthRecord.getPtmzCount()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getPtmzCount()), new BigDecimal(preMonthRecord.getPtmzCount()),true)+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getPtmzCount()), new BigDecimal(preMonthRecord.getPtmzCount()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getPtmzCount()), new BigDecimal(preMonthRecord.getPtmzCount()))+"%。";

		
		outPatientJzyslxInfo.setNote(note);
		List<String> typeList = new LinkedList<>();
		typeList.add("知名专家门诊");
		typeList.add("主任医师门诊");
		typeList.add("副主任医师门诊");
		typeList.add("普通门诊");
		typeList.add("急诊");
		
		outPatientJzyslxInfo.setTypeList(typeList);
		
		
		List<Map<String,Object>> typeValueList = new LinkedList<>();
		Map<String,Object> map1 = new HashMap<>();
		map1.put("name", "知名专家门诊");
		map1.put("value", record.getZmzjmzCount());
		typeValueList.add(map1);
		
		Map<String,Object> map2 = new HashMap<>();
		map2.put("name", "主任医师门诊");
		map2.put("value", record.getZrysmzCount());
		typeValueList.add(map2);
		
		
		Map<String,Object> map3 = new HashMap<>();
		map3.put("name", "副主任医师门诊");
		map3.put("value", record.getFzrysmzCount());
		typeValueList.add(map3);
		
		
		Map<String,Object> map4 = new HashMap<>();
		map4.put("name", "普通门诊");
		map4.put("value", record.getPtmzCount());
		typeValueList.add(map4);
		
		Map<String,Object> map5 = new HashMap<>();
		map5.put("name", "急诊");
		map5.put("value", record.getPtmzCount());
		typeValueList.add(map5);
		
		outPatientJzyslxInfo.setParamList(typeValueList);
		return  outPatientJzyslxInfo;
		
	}
	
	
	public OutpatientJzyslx getOutPatientJzyslxRecord(String startTime,String endTime,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setOrgCode(orgCode);
		return  mrInBasicMapper.getOutpatientJzyslx(outPatientParam);
		
	}

	@Override
	public OutpatientSexInfo getOutpatientSexInfo(StatisticalReportParam statisticalReportParam) {
		OutpatientSex record = getOutpatientSexRecord(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),statisticalReportParam.getOrganizationId());
		record.init();
		OutpatientSex preMonthRecord = getOutpatientSexRecord(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),statisticalReportParam.getOrganizationId());
		preMonthRecord.init();
		OutpatientSex lastYearRecord = getOutpatientSexRecord(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),statisticalReportParam.getOrganizationId());
		lastYearRecord.init();
		String note = 
				"    "+statisticalReportParam.getStatics1Name()+"门急诊就诊患者中男性患者"+record.getManCount()+"人次，占比为"+BigDecimalUtil.getDivideRate(new BigDecimal(record.getManCount()), new BigDecimal(record.getTotalCount()))+"%；女性患者"+record.getWomenCount()+"人次，占比为"+BigDecimalUtil.getDivideRate(new BigDecimal(record.getWomenCount()), new BigDecimal(record.getTotalCount()))+"%。\n"+
				"    "+statisticalReportParam.getStatics1Name()+"月男性患者占比"+record.getManRate()+"%比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getManRate()+"%"+BigDecimalUtil.getCompareResult(record.getManRate(), lastYearRecord.getManRate())+""+BigDecimalUtil.getNumDifference(record.getManRate(), lastYearRecord.getManRate())+"%，"+BigDecimalUtil.getCompareRateResult(record.getManRate(), lastYearRecord.getManRate())+"为"+BigDecimalUtil.getCompareRate(record.getManRate(), lastYearRecord.getManRate())+"%，比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getManRate()+"%"+BigDecimalUtil.getCompareResult(record.getManRate(), preMonthRecord.getManRate())+BigDecimalUtil.getNumDifference(record.getManRate(), preMonthRecord.getManRate())+"%，"+BigDecimalUtil.getCompareRateResult(record.getManRate(), preMonthRecord.getManRate())+"为"+BigDecimalUtil.getCompareRate(record.getManRate(), preMonthRecord.getManRate())+"%。\n"+
				"    "+statisticalReportParam.getStatics1Name()+"女性患者占为"+record.getWomanRate()+"%比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getWomanRate()+"%，"+BigDecimalUtil.getCompareRateResult(record.getWomanRate(), preMonthRecord.getWomanRate())+"为"+BigDecimalUtil.getCompareRate(record.getWomanRate(), preMonthRecord.getWomanRate())+"%，比"+statisticalReportParam.getStatics2Name()+"的"+lastYearRecord.getWomanRate()+"%"+BigDecimalUtil.getCompareResult(record.getWomanRate(), preMonthRecord.getWomanRate())+BigDecimalUtil.getNumDifference(record.getWomanRate(), preMonthRecord.getWomanRate())+"%，"+BigDecimalUtil.getCompareRateResult(record.getWomanRate(), preMonthRecord.getWomanRate())+"为"+BigDecimalUtil.getCompareRate(record.getWomanRate(), preMonthRecord.getWomanRate())+"%。\n";

		OutpatientSexInfo outpatientSexInfo = new OutpatientSexInfo();
		outpatientSexInfo.setNote(note);
		
		
		return outpatientSexInfo;
	}
	
	
	public OutpatientSex getOutpatientSexRecord(String startTime,String endTime,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setOrgCode(orgCode);
		return  mrInBasicMapper.getOutpatientSex(outPatientParam);
		
	}

	
	
	@Override
	public OutPatientAgeInfo getOutpatientAgeInfo(StatisticalReportParam statisticalReportParam) {
		OutPatientAge record = getOutpatientAge(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),statisticalReportParam.getOrganizationId());
		record.init();
		OutPatientAge preMonthRecord = getOutpatientAge(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),statisticalReportParam.getOrganizationId());
		preMonthRecord.init();
		OutPatientAge lastYearRecord = getOutpatientAge(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),statisticalReportParam.getOrganizationId());
		lastYearRecord.init();
		String note ="    "+statisticalReportParam.getStatics1Name()+"门急诊就诊患者平均年龄为"+record.getAvgYear()+"岁，比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getAvgYear()+"岁"+BigDecimalUtil.getCompareResult(record.getAvgYear(), lastYearRecord.getAvgYear())+BigDecimalUtil.getNumDifference(record.getAvgYear(),lastYearRecord.getAvgYear())+"岁，"+BigDecimalUtil.getCompareRateResult(record.getAvgYear(),lastYearRecord.getAvgYear())+"为"+BigDecimalUtil.getCompareRate(record.getAvgYear(), lastYearRecord.getAvgYear())+"%，"
						+ "比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getAvgYear()+"岁"+BigDecimalUtil.getCompareResult(record.getAvgYear(), preMonthRecord.getAvgYear())+""+BigDecimalUtil.getNumDifference(record.getAvgYear(), preMonthRecord.getAvgYear())+"岁，"+BigDecimalUtil.getCompareRateResult(record.getAvgYear(), preMonthRecord.getAvgYear())+"为"+BigDecimalUtil.getCompareRate(record.getAvgYear(), preMonthRecord.getAvgYear())+"%。";
		
		OutPatientAgeInfo outPatientAgeInfo = new OutPatientAgeInfo();
		outPatientAgeInfo.setNote(note);
		
		List<OutPatientAgeRecord> outPatientAgeRecords= new LinkedList<>();
		OutPatientAgeRecord year5Record = new OutPatientAgeRecord();
		year5Record.setTitle("5岁以下");
		year5Record.setNum(record.getYear5Count());
		year5Record.setRate(record.getYear5Rate());
		year5Record.setLastYearNum(lastYearRecord.getYear5Count());
		year5Record.setLastYearRate(lastYearRecord.getYear5Rate());
		year5Record.setPreMonthNum(preMonthRecord.getYear5Count());
		year5Record.setPreMonthRate(preMonthRecord.getYear5Rate());
		outPatientAgeRecords.add(year5Record);
		
		OutPatientAgeRecord year14Record = new OutPatientAgeRecord();
		year14Record.setTitle("5-14岁");
		year14Record.setNum(record.getYear14Count());
		year14Record.setRate(record.getYear14Rate());
		year14Record.setLastYearNum(lastYearRecord.getYear14Count());
		year14Record.setLastYearRate(lastYearRecord.getYear14Rate());
		year14Record.setPreMonthNum(preMonthRecord.getYear14Count());
		year14Record.setPreMonthRate(preMonthRecord.getYear14Rate());
		outPatientAgeRecords.add(year14Record);
		
		OutPatientAgeRecord year44Record = new OutPatientAgeRecord();
		year44Record.setTitle("15-44岁");
		year44Record.setNum(record.getYear44Count());
		year44Record.setRate(record.getYear44Rate());
		year44Record.setLastYearNum(lastYearRecord.getYear44Count());
		year44Record.setLastYearRate(lastYearRecord.getYear44Rate());
		year44Record.setPreMonthNum(preMonthRecord.getYear44Count());
		year44Record.setPreMonthRate(preMonthRecord.getYear44Rate());
		outPatientAgeRecords.add(year44Record);
		
		OutPatientAgeRecord year60Record = new OutPatientAgeRecord();
		year60Record.setTitle("45-60岁");
		year60Record.setNum(record.getYear60Count());
		year60Record.setRate(record.getYear60Rate());
		year60Record.setLastYearNum(lastYearRecord.getYear60Count());
		year60Record.setLastYearRate(lastYearRecord.getYear60Rate());
		year60Record.setPreMonthNum(preMonthRecord.getYear60Count());
		year60Record.setPreMonthRate(preMonthRecord.getYear60Rate());
		outPatientAgeRecords.add(year60Record);
		
		OutPatientAgeRecord year60MoreRecord = new OutPatientAgeRecord();
		year60MoreRecord.setTitle("60岁以上");
		year60MoreRecord.setNum(record.getYearMoreCount());
		year60MoreRecord.setRate(record.getYearMoreRate());
		year60MoreRecord.setLastYearNum(lastYearRecord.getYearMoreCount());
		year60MoreRecord.setLastYearRate(lastYearRecord.getYearMoreRate());
		year60MoreRecord.setPreMonthNum(preMonthRecord.getYearMoreCount());
		year60MoreRecord.setPreMonthRate(preMonthRecord.getYearMoreRate());
		outPatientAgeRecords.add(year60MoreRecord);
		
		
		OutPatientAgeRecord yearTotalRecord = new OutPatientAgeRecord();
		yearTotalRecord.setTitle("合计");
		yearTotalRecord.setNum(record.getTotalCount());
		yearTotalRecord.setRate(new BigDecimal(100));
		yearTotalRecord.setLastYearNum(lastYearRecord.getTotalCount());
		yearTotalRecord.setLastYearRate(new BigDecimal(100));
		yearTotalRecord.setPreMonthNum(preMonthRecord.getTotalCount());
		yearTotalRecord.setPreMonthRate(new BigDecimal(100));
		outPatientAgeRecords.add(yearTotalRecord);
		outPatientAgeInfo.setRecordList(outPatientAgeRecords);
		return outPatientAgeInfo;
	}
	
	
	
	
	public OutPatientAge getOutpatientAge(String startTime,String endTime,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setOrgCode(orgCode);
		return  mrInBasicMapper.getOutPatientAge(outPatientParam);
		
	}

	@Override
	public OutPatientAreaInfo getOutpatientAreaInfo(StatisticalReportParam statisticalReportParam) {
		OutpatientArea record = getOutpatientArea(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),statisticalReportParam.getOrganizationId());
		record.init();
		System.out.println(record);
		OutpatientArea preMonthRecord = getOutpatientArea(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),statisticalReportParam.getOrganizationId());
		preMonthRecord.init();
		System.out.println(preMonthRecord);
		OutpatientArea lastYearRecord = getOutpatientArea(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),statisticalReportParam.getOrganizationId());
		lastYearRecord.init();
		System.out.println(lastYearRecord);
		
		String note = 
				"    "+statisticalReportParam.getStatics1Name()+"门急诊就诊患者中来自其他省份的有"+record.getOtherSdNum()+"人次，占比为"+record.getOtherSdRate()+"%，比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getOtherSdNum()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getOtherSdNum()), new BigDecimal(lastYearRecord.getOtherSdNum()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getOtherSdNum()), new BigDecimal(lastYearRecord.getOtherSdNum()))+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getOtherSdNum()), new BigDecimal(lastYearRecord.getOtherSdNum()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getOtherSdNum()), new BigDecimal(lastYearRecord.getOtherSdNum()))+"%，比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getOtherSdNum()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getOtherSdNum()), new BigDecimal(preMonthRecord.getOtherSdNum()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getOtherSdNum()), new BigDecimal(preMonthRecord.getOtherSdNum()))+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getOtherSdNum()), new BigDecimal(preMonthRecord.getOtherSdNum()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getOtherSdNum()), new BigDecimal(preMonthRecord.getOtherSdNum()))+"%。"+
				"其他省份来源患者占比"+record.getOtherSdRate()+"比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getOtherSdRate()+"%"+BigDecimalUtil.getCompareResult(record.getOtherSdRate(), lastYearRecord.getOtherSdRate())+""+BigDecimalUtil.getNumDifference(record.getOtherSdRate(), lastYearRecord.getOtherSdRate())+"%，"+BigDecimalUtil.getCompareRateResult(record.getOtherSdRate(), lastYearRecord.getOtherSdRate())+"为"+BigDecimalUtil.getCompareRate(record.getOtherSdRate(), lastYearRecord.getOtherSdRate())+"%，比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getOtherSdRate()+"%"+BigDecimalUtil.getCompareResult(record.getOtherSdRate(), preMonthRecord.getOtherSdRate())+""+BigDecimalUtil.getNumDifference(record.getOtherSdRate(), preMonthRecord.getOtherSdRate())+"%，"+BigDecimalUtil.getCompareRateResult(record.getOtherSdRate(), preMonthRecord.getOtherSdRate())+"为"+BigDecimalUtil.getCompareRate(record.getOtherSdRate(), preMonthRecord.getOtherSdRate())+"%。\n"+
				"    "+statisticalReportParam.getStatics1Name()+"门急诊就诊患者中来自济南市以外地区的（包括省外和省内非济南地区）有"+record.getOtherJinanNum()+"人次，占比为"+record.getOtherJinanRate()+"%，"
				+ "比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getOtherJinanNum()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getOtherJinanNum()), new BigDecimal(lastYearRecord.getOtherJinanNum()))+BigDecimalUtil.getNumDifference(new BigDecimal(record.getOtherJinanNum()), new BigDecimal(lastYearRecord.getOtherJinanNum()))+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getOtherJinanNum()), new BigDecimal(lastYearRecord.getOtherJinanNum()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getOtherJinanNum()), new BigDecimal(lastYearRecord.getOtherJinanNum()))+"%，比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getOtherJinanNum()+"人次"+BigDecimalUtil.getCompareResult(new BigDecimal(record.getOtherJinanNum()), new BigDecimal(preMonthRecord.getOtherJinanNum()))+""+BigDecimalUtil.getNumDifference(new BigDecimal(record.getOtherJinanNum()), new BigDecimal(preMonthRecord.getOtherJinanNum()))+"人次，"+BigDecimalUtil.getCompareRateResult(new BigDecimal(record.getOtherJinanNum()), new BigDecimal(preMonthRecord.getOtherJinanNum()))+"为"+BigDecimalUtil.getCompareRate(new BigDecimal(record.getOtherJinanNum()), new BigDecimal(preMonthRecord.getOtherJinanNum()))+"%。"
				+ "非济南市患者占比比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getOtherJinanRate()+"%"+BigDecimalUtil.getCompareResult(record.getOtherJinanRate(), lastYearRecord.getOtherJinanRate())+BigDecimalUtil.getNumDifference(record.getOtherJinanRate(), lastYearRecord.getOtherJinanRate())+"%，"+BigDecimalUtil.getCompareRateResult(record.getOtherJinanRate(), lastYearRecord.getOtherJinanRate())+"为"+BigDecimalUtil.getCompareRate(record.getOtherJinanRate(), lastYearRecord.getOtherJinanRate())+"%，"
				+ "比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getOtherJinanRate()+"%"+BigDecimalUtil.getCompareResult(record.getOtherJinanRate(), preMonthRecord.getOtherJinanRate())+BigDecimalUtil.getNumDifference(record.getOtherJinanRate(), preMonthRecord.getOtherJinanRate())+"%，"+BigDecimalUtil.getCompareRateResult(record.getOtherJinanRate(), preMonthRecord.getOtherJinanRate())+"为"+BigDecimalUtil.getCompareRate(record.getOtherJinanRate(), preMonthRecord.getOtherJinanRate())+"%。详见下表。";

		
		System.out.println(note);
		
		OutPatientAreaInfo outPatientAreaInfo = new OutPatientAreaInfo();
		outPatientAreaInfo.setNote(note);
		
		List<OutPatientAreaRecord> list = new LinkedList<>();
		OutPatientAreaRecord outPatientAreaRecord = new OutPatientAreaRecord();
		outPatientAreaRecord.setTitle("其他省份");
		outPatientAreaRecord.setNum(record.getOtherSdNum()+"");
		outPatientAreaRecord.setRate(record.getOtherSdRate());
		outPatientAreaRecord.setPreMonthNum(preMonthRecord.getOtherSdNum()+"");
		outPatientAreaRecord.setPreMonthRate(preMonthRecord.getOtherSdRate());
		outPatientAreaRecord.setLastYearMonthNum(lastYearRecord.getOtherSdNum()+"");
		outPatientAreaRecord.setLastYearRate(lastYearRecord.getOtherSdRate());
		outPatientAreaRecord.setTbRate(BigDecimalUtil.getHbRate(record.getOtherSdRate(), lastYearRecord.getOtherSdRate()));
		outPatientAreaRecord.setHbRate(BigDecimalUtil.getHbRate(record.getOtherSdRate(), preMonthRecord.getOtherSdRate()));
		list.add(outPatientAreaRecord);
		
		OutPatientAreaRecord jinanRecord = new OutPatientAreaRecord();
		jinanRecord.setTitle("济南市");
		jinanRecord.setNum(record.getJinanNum()+"");
		jinanRecord.setRate(record.getJinanRate());
		jinanRecord.setPreMonthNum(preMonthRecord.getJinanNum()+"");
		jinanRecord.setPreMonthRate(preMonthRecord.getJinanRate());
		jinanRecord.setLastYearMonthNum(lastYearRecord.getJinanNum()+"");
		jinanRecord.setLastYearRate(lastYearRecord.getJinanRate());
		jinanRecord.setTbRate(BigDecimalUtil.getHbRate(record.getJinanRate(), lastYearRecord.getJinanRate()));
		jinanRecord.setHbRate(BigDecimalUtil.getHbRate(record.getJinanRate(), preMonthRecord.getJinanRate()));
		list.add(jinanRecord);
		
		OutPatientAreaRecord otherJinanRecord = new OutPatientAreaRecord();
		otherJinanRecord.setTitle("省内其他地市");
		otherJinanRecord.setNum(record.getOtherJinanNum()+"");
		otherJinanRecord.setRate(record.getOtherJinanRate());
		otherJinanRecord.setPreMonthNum(preMonthRecord.getOtherJinanNum()+"");
		otherJinanRecord.setPreMonthRate(preMonthRecord.getOtherJinanRate());
		otherJinanRecord.setLastYearMonthNum(lastYearRecord.getOtherJinanNum()+"");
		otherJinanRecord.setLastYearRate(lastYearRecord.getOtherJinanRate());
		otherJinanRecord.setTbRate(BigDecimalUtil.getHbRate(record.getOtherJinanRate(), lastYearRecord.getOtherJinanRate()));
		otherJinanRecord.setHbRate(BigDecimalUtil.getHbRate(record.getOtherJinanRate(), preMonthRecord.getOtherJinanRate()));
		list.add(otherJinanRecord);
		
		OutPatientAreaRecord dezhouRecord = new OutPatientAreaRecord();
		dezhouRecord.setTitle("德州市");
		dezhouRecord.setNum(record.getDezhouNum()+"");
		dezhouRecord.setRate(record.getDezhouRate());
		dezhouRecord.setPreMonthNum(preMonthRecord.getDezhouNum()+"");
		dezhouRecord.setPreMonthRate(preMonthRecord.getOtherJinanRate());
		dezhouRecord.setLastYearMonthNum(lastYearRecord.getDezhouNum()+"");
		dezhouRecord.setLastYearRate(lastYearRecord.getDezhouRate());
		dezhouRecord.setTbRate(BigDecimalUtil.getHbRate(record.getDezhouRate(), lastYearRecord.getDezhouRate()));
		dezhouRecord.setHbRate(BigDecimalUtil.getHbRate(record.getDezhouRate(), preMonthRecord.getDezhouRate()));
		list.add(dezhouRecord);
		
		OutPatientAreaRecord hezeRecord = new OutPatientAreaRecord();
		hezeRecord.setTitle("菏泽市");
		hezeRecord.setNum(record.getHezeNum()+"");
		hezeRecord.setRate(record.getHezeRate());
		hezeRecord.setPreMonthNum(preMonthRecord.getHezeNum()+"");
		hezeRecord.setPreMonthRate(preMonthRecord.getHezeRate());
		hezeRecord.setLastYearMonthNum(lastYearRecord.getHezeNum()+"");
		hezeRecord.setLastYearRate(lastYearRecord.getHezeRate());
		hezeRecord.setTbRate(BigDecimalUtil.getHbRate(record.getHezeRate(), lastYearRecord.getHezeRate()));
		hezeRecord.setHbRate(BigDecimalUtil.getHbRate(record.getHezeRate(), preMonthRecord.getHezeRate()));
		list.add(hezeRecord);
		
		OutPatientAreaRecord liaochengRecord = new OutPatientAreaRecord();
		liaochengRecord.setTitle("聊城市");
		liaochengRecord.setNum(record.getLiaochengNum()+"");
		liaochengRecord.setRate(record.getLiaochengRate());
		liaochengRecord.setPreMonthNum(preMonthRecord.getLiaochengNum()+"");
		liaochengRecord.setPreMonthRate(preMonthRecord.getLiaochengRate());
		liaochengRecord.setLastYearMonthNum(lastYearRecord.getLiaochengNum()+"");
		liaochengRecord.setLastYearRate(lastYearRecord.getLiaochengRate());
		liaochengRecord.setTbRate(BigDecimalUtil.getHbRate(record.getLiaochengRate(), lastYearRecord.getLiaochengRate()));
		liaochengRecord.setHbRate(BigDecimalUtil.getHbRate(record.getLiaochengRate(), preMonthRecord.getLiaochengRate()));
		list.add(liaochengRecord);
		
		OutPatientAreaRecord jiningRecord = new OutPatientAreaRecord();
		jiningRecord.setTitle("济宁市");
		jiningRecord.setNum(record.getJiningNum()+"");
		jiningRecord.setRate(record.getJiningRate());
		jiningRecord.setPreMonthNum(preMonthRecord.getJiningNum()+"");
		jiningRecord.setPreMonthRate(preMonthRecord.getJiningRate());
		jiningRecord.setLastYearMonthNum(lastYearRecord.getJiningNum()+"");
		jiningRecord.setLastYearRate(lastYearRecord.getJiningRate());
		jiningRecord.setTbRate(BigDecimalUtil.getHbRate(record.getJiningRate(), lastYearRecord.getJiningRate()));
		jiningRecord.setHbRate(BigDecimalUtil.getHbRate(record.getJiningRate(), preMonthRecord.getJiningRate()));
		list.add(jiningRecord);
		
		OutPatientAreaRecord taianRecord = new OutPatientAreaRecord();
		taianRecord.setTitle("泰安市");
		taianRecord.setNum(record.getTaianNum()+"");
		taianRecord.setRate(record.getTaianRate());
		taianRecord.setPreMonthNum(preMonthRecord.getTaianNum()+"");
		taianRecord.setPreMonthRate(preMonthRecord.getTaianRate());
		taianRecord.setLastYearMonthNum(lastYearRecord.getTaianNum()+"");
		taianRecord.setLastYearRate(lastYearRecord.getTaianRate());
		taianRecord.setTbRate(BigDecimalUtil.getHbRate(record.getTaianRate(), lastYearRecord.getTaianRate()));
		taianRecord.setHbRate(BigDecimalUtil.getHbRate(record.getTaianRate(), preMonthRecord.getTaianRate()));
		list.add(taianRecord);
		
		OutPatientAreaRecord linxiRecord = new OutPatientAreaRecord();
		linxiRecord.setTitle("临沂市");
		linxiRecord.setNum(record.getLinxiNum()+"");
		linxiRecord.setRate(record.getLinxiRate());
		linxiRecord.setPreMonthNum(preMonthRecord.getLinxiNum()+"");
		linxiRecord.setPreMonthRate(preMonthRecord.getLinxiRate());
		linxiRecord.setLastYearMonthNum(lastYearRecord.getLinxiNum()+"");
		linxiRecord.setLastYearRate(lastYearRecord.getLinxiRate());
		linxiRecord.setTbRate(BigDecimalUtil.getHbRate(record.getLinxiRate(), lastYearRecord.getLinxiRate()));
		linxiRecord.setHbRate(BigDecimalUtil.getHbRate(record.getLinxiRate(), preMonthRecord.getLinxiRate()));
		list.add(linxiRecord);
		
		
		OutPatientAreaRecord ziboRecord = new OutPatientAreaRecord();
		ziboRecord.setTitle("淄博市");
		ziboRecord.setNum(record.getZiboNum()+"");
		ziboRecord.setRate(record.getZiboRate());
		ziboRecord.setPreMonthNum(preMonthRecord.getZiboNum()+"");
		ziboRecord.setPreMonthRate(preMonthRecord.getZiboRate());
		ziboRecord.setLastYearMonthNum(lastYearRecord.getZiboNum()+"");
		ziboRecord.setLastYearRate(lastYearRecord.getZiboRate());
		ziboRecord.setTbRate(BigDecimalUtil.getHbRate(record.getZiboRate(), lastYearRecord.getZiboRate()));
		ziboRecord.setHbRate(BigDecimalUtil.getHbRate(record.getZiboRate(), preMonthRecord.getZiboRate()));
		list.add(ziboRecord);
		
		
		OutPatientAreaRecord binzhouRecord = new OutPatientAreaRecord();
		binzhouRecord.setTitle("滨州市");
		binzhouRecord.setNum(record.getBinzhouNum()+"");
		binzhouRecord.setRate(record.getBinzhouRate());
		binzhouRecord.setPreMonthNum(preMonthRecord.getBinzhouNum()+"");
		binzhouRecord.setPreMonthRate(preMonthRecord.getBinzhouRate());
		binzhouRecord.setLastYearMonthNum(lastYearRecord.getBinzhouNum()+"");
		binzhouRecord.setLastYearRate(lastYearRecord.getBinzhouRate());
		binzhouRecord.setTbRate(BigDecimalUtil.getHbRate(record.getBinzhouRate(), lastYearRecord.getBinzhouRate()));
		binzhouRecord.setHbRate(BigDecimalUtil.getHbRate(record.getBinzhouRate(), preMonthRecord.getBinzhouRate()));
		list.add(binzhouRecord);
		
		OutPatientAreaRecord weifangRecord = new OutPatientAreaRecord();
		weifangRecord.setTitle("潍坊市");
		weifangRecord.setNum(record.getWeifangNum()+"");
		weifangRecord.setRate(record.getWeifangRate());
		weifangRecord.setPreMonthNum(preMonthRecord.getWeifangNum()+"");
		weifangRecord.setPreMonthRate(preMonthRecord.getWeifangRate());
		weifangRecord.setLastYearMonthNum(lastYearRecord.getWeifangNum()+"");
		weifangRecord.setLastYearRate(lastYearRecord.getWeifangRate());
		weifangRecord.setTbRate(BigDecimalUtil.getHbRate(record.getWeifangRate(), lastYearRecord.getWeifangRate()));
		weifangRecord.setHbRate(BigDecimalUtil.getHbRate(record.getWeifangRate(), preMonthRecord.getWeifangRate()));
		list.add(weifangRecord);
		
		OutPatientAreaRecord zaozhaungRecord = new OutPatientAreaRecord();
		zaozhaungRecord.setTitle("枣庄市");
		zaozhaungRecord.setNum(record.getZaozhaungNum()+"");
		zaozhaungRecord.setRate(record.getZaozhaungRate());
		zaozhaungRecord.setPreMonthNum(preMonthRecord.getZaozhaungNum()+"");
		zaozhaungRecord.setPreMonthRate(preMonthRecord.getZaozhaungRate());
		zaozhaungRecord.setLastYearMonthNum(lastYearRecord.getZaozhaungNum()+"");
		zaozhaungRecord.setLastYearRate(lastYearRecord.getZaozhaungRate());
		zaozhaungRecord.setTbRate(BigDecimalUtil.getHbRate(record.getZaozhaungRate(), lastYearRecord.getZaozhaungRate()));
		zaozhaungRecord.setHbRate(BigDecimalUtil.getHbRate(record.getZaozhaungRate(), preMonthRecord.getZaozhaungRate()));
		list.add(zaozhaungRecord);
		
		
		OutPatientAreaRecord yantaiRecord = new OutPatientAreaRecord();
		yantaiRecord.setTitle("烟台市");
		yantaiRecord.setNum(record.getYantaiNum()+"");
		yantaiRecord.setRate(record.getYantaiRate());
		yantaiRecord.setPreMonthNum(preMonthRecord.getYantaiNum()+"");
		yantaiRecord.setPreMonthRate(preMonthRecord.getYantaiRate());
		yantaiRecord.setLastYearMonthNum(lastYearRecord.getYantaiNum()+"");
		yantaiRecord.setLastYearRate(lastYearRecord.getYantaiRate());
		yantaiRecord.setTbRate(BigDecimalUtil.getHbRate(record.getYantaiRate(), lastYearRecord.getYantaiRate()));
		yantaiRecord.setHbRate(BigDecimalUtil.getHbRate(record.getYantaiRate(), preMonthRecord.getYantaiRate()));
		list.add(yantaiRecord);
		
		OutPatientAreaRecord dongyingRecord = new OutPatientAreaRecord();
		dongyingRecord.setTitle("东营市");
		dongyingRecord.setNum(record.getDongyingNum()+"");
		dongyingRecord.setRate(record.getDongyingRate());
		dongyingRecord.setPreMonthNum(preMonthRecord.getDongyingNum()+"");
		dongyingRecord.setPreMonthRate(preMonthRecord.getDongyingRate());
		dongyingRecord.setLastYearMonthNum(lastYearRecord.getDongyingNum()+"");
		dongyingRecord.setLastYearRate(lastYearRecord.getDongyingRate());
		dongyingRecord.setTbRate(BigDecimalUtil.getHbRate(record.getDongyingRate(), lastYearRecord.getDongyingRate()));
		dongyingRecord.setHbRate(BigDecimalUtil.getHbRate(record.getDongyingRate(), preMonthRecord.getDongyingRate()));
		list.add(dongyingRecord);
		
		OutPatientAreaRecord qingdaoRecord = new OutPatientAreaRecord();
		qingdaoRecord.setTitle("青岛市");
		qingdaoRecord.setNum(record.getQingdaoNum()+"");
		qingdaoRecord.setRate(record.getQingdaoRate());
		qingdaoRecord.setPreMonthNum(preMonthRecord.getQingdaoNum()+"");
		qingdaoRecord.setPreMonthRate(preMonthRecord.getQingdaoRate());
		qingdaoRecord.setLastYearMonthNum(lastYearRecord.getQingdaoNum()+"");
		qingdaoRecord.setLastYearRate(lastYearRecord.getQingdaoRate());
		qingdaoRecord.setTbRate(BigDecimalUtil.getHbRate(record.getQingdaoRate(), lastYearRecord.getQingdaoRate()));
		qingdaoRecord.setHbRate(BigDecimalUtil.getHbRate(record.getQingdaoRate(), preMonthRecord.getQingdaoRate()));
		list.add(qingdaoRecord);
		
		OutPatientAreaRecord rizhaoRecord = new OutPatientAreaRecord();
		rizhaoRecord.setTitle("日照市");
		rizhaoRecord.setNum(record.getRizhaoNum()+"");
		rizhaoRecord.setRate(record.getRizhaoRate());
		rizhaoRecord.setPreMonthNum(preMonthRecord.getRizhaoNum()+"");
		rizhaoRecord.setPreMonthRate(preMonthRecord.getRizhaoRate());
		rizhaoRecord.setLastYearMonthNum(lastYearRecord.getRizhaoNum()+"");
		rizhaoRecord.setLastYearRate(lastYearRecord.getRizhaoRate());
		rizhaoRecord.setTbRate(BigDecimalUtil.getHbRate(record.getRizhaoRate(), lastYearRecord.getRizhaoRate()));
		rizhaoRecord.setHbRate(BigDecimalUtil.getHbRate(record.getRizhaoRate(), preMonthRecord.getRizhaoRate()));
		list.add(rizhaoRecord);
		
		
		OutPatientAreaRecord weihaiRecord = new OutPatientAreaRecord();
		weihaiRecord.setTitle("威海市");
		weihaiRecord.setNum(record.getWeihaiNum()+"");
		weihaiRecord.setRate(record.getWeihaiRate());
		weihaiRecord.setPreMonthNum(preMonthRecord.getWeihaiNum()+"");
		weihaiRecord.setPreMonthRate(preMonthRecord.getWeihaiRate());
		weihaiRecord.setLastYearMonthNum(lastYearRecord.getWeihaiNum()+"");
		weihaiRecord.setLastYearRate(lastYearRecord.getWeihaiRate());
		weihaiRecord.setTbRate(BigDecimalUtil.getHbRate(record.getWeihaiRate(), lastYearRecord.getWeihaiRate()));
		weihaiRecord.setHbRate(BigDecimalUtil.getHbRate(record.getWeihaiRate(), preMonthRecord.getWeihaiRate()));
		list.add(weihaiRecord);
		
		
		outPatientAreaInfo.setList(list);
		
		return outPatientAreaInfo;
	}
	
	
	
	
	public OutpatientArea getOutpatientArea(String startTime,String endTime,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setOrgCode(orgCode);
		return  mrInBasicMapper.getOutpatientArea(outPatientParam);
		
	}

	@Override
	public OutPatientFeeInfo getOutpatientFeeInfo(StatisticalReportParam statisticalReportParam) {

		OutpatientFee record = getOutpatientFee(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),statisticalReportParam.getOrganizationId());
		OutpatientFee preMonthRecord = getOutpatientFee(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),statisticalReportParam.getOrganizationId());
		OutpatientFee lastYearRecord = getOutpatientFee(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),statisticalReportParam.getOrganizationId());
		
		String note ="    "+statisticalReportParam.getStatics1Name()+"全院门急诊患者总费用为"+record.getTotalFee()+"万元，"
					+ "比"+statisticalReportParam.getStatics3Name()+"的"+lastYearRecord.getTotalFee()+"万元"+BigDecimalUtil.getCompareResult(record.getTotalFee(), lastYearRecord.getTotalFee())+BigDecimalUtil.getNumDifference(record.getTotalFee(), lastYearRecord.getTotalFee())+"万元，"+BigDecimalUtil.getCompareRateResult(record.getTotalFee(), lastYearRecord.getTotalFee())+"为"+BigDecimalUtil.getCompareRate(record.getTotalFee(), lastYearRecord.getTotalFee())+"%；"
					+ "比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getTotalFee()+"万元"+BigDecimalUtil.getCompareResult(record.getTotalFee(), preMonthRecord.getTotalFee())+BigDecimalUtil.getNumDifference(record.getTotalFee(), preMonthRecord.getTotalFee())+"万元，"+BigDecimalUtil.getCompareRateResult(record.getTotalFee(), preMonthRecord.getTotalFee())+"为"+BigDecimalUtil.getCompareRate(record.getTotalFee(), preMonthRecord.getTotalFee())+"%。\n"+
					 "    "+statisticalReportParam.getStatics1Name()+"门急诊患者次均费用"+record.getAvgFee()+"元，"
					 + "比"+statisticalReportParam.getStatics3Name()+""+lastYearRecord.getAvgFee()+"元"+BigDecimalUtil.getCompareResult(record.getAvgFee(), lastYearRecord.getAvgFee())+BigDecimalUtil.getNumDifference(record.getAvgFee(), lastYearRecord.getAvgFee())+"元，"+BigDecimalUtil.getCompareRateResult(record.getAvgFee(), lastYearRecord.getAvgFee())+"为"+BigDecimalUtil.getCompareRate(record.getAvgFee(), lastYearRecord.getAvgFee())+"%；"
					 + "比"+statisticalReportParam.getStatics2Name()+"的"+preMonthRecord.getAvgFee()+"元"+BigDecimalUtil.getCompareResult(record.getAvgFee(), preMonthRecord.getAvgFee())+BigDecimalUtil.getNumDifference(record.getAvgFee(), preMonthRecord.getAvgFee())+"元，"+BigDecimalUtil.getCompareRateResult(record.getAvgFee(), preMonthRecord.getAvgFee())+"为"+BigDecimalUtil.getCompareRate(record.getAvgFee(), preMonthRecord.getAvgFee())+"%。";

		OutPatientFeeInfo outPatientFeeInfo = new OutPatientFeeInfo();
		outPatientFeeInfo.setNote(note);
		
		return outPatientFeeInfo;
	}
	
	
	public OutpatientFee getOutpatientFee(String startTime,String endTime,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setOrgCode(orgCode);
		return  mrInBasicMapper.getOutpatientFee(outPatientParam);
		
	}

	@Override
	public OutpatientDiagTop20Info getOutpatientDiagTop20(StatisticalReportParam statisticalReportParam) {
		List<OutpatientDiagTop20> records = getOutpatientDiagTop20(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),statisticalReportParam.getOrganizationId());
		List<OutpatientDiagTop20> preMonthRecords = getOutpatientDiagTop20(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),statisticalReportParam.getOrganizationId());
		List<OutpatientDiagTop20> lastYearRecords = getOutpatientDiagTop20(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),statisticalReportParam.getOrganizationId());
		
		List<OutpatientDiagTop20Record> list = new LinkedList<OutpatientDiagTop20Record>();
		
		OutpatientDiagTop20Info outpatientDiagTop20Info = new OutpatientDiagTop20Info();
		
		if(CollectionUtils.isNotEmpty(records)) {
			OutpatientDiagTop20Record outpatientDiagTop20Record = null ;
			int i =1;
			for (OutpatientDiagTop20 outpatientDiagTop20 : records) {
				outpatientDiagTop20Record = new OutpatientDiagTop20Record();
				if(outpatientDiagTop20.getR().intValue()==i) {
					outpatientDiagTop20Record.setIndex(i);
					outpatientDiagTop20Record.setDiagname(outpatientDiagTop20.getDiagnoss());
					outpatientDiagTop20Record.setNum(outpatientDiagTop20.getNum());
					outpatientDiagTop20Record.setAvg(outpatientDiagTop20.getAvgFee());
				}
				
				if(CollectionUtils.isNotEmpty(preMonthRecords)) {
					for (OutpatientDiagTop20 preOutpatientDiagTop20 : preMonthRecords) {
						if(preOutpatientDiagTop20.getR().intValue()==i) {
							outpatientDiagTop20Record.setPreMonthAvg(preOutpatientDiagTop20.getAvgFee());
							outpatientDiagTop20Record.setPreMonthNum(preOutpatientDiagTop20.getNum());
							outpatientDiagTop20Record.setPreMonthDiagname(preOutpatientDiagTop20.getDiagnoss());
						}
					
					}
				}
				
				if(CollectionUtils.isNotEmpty(lastYearRecords)) {
					for (OutpatientDiagTop20 lastOutpatientDiagTop20 : lastYearRecords) {
						if(lastOutpatientDiagTop20.getR().intValue()==i) {
							outpatientDiagTop20Record.setLastYearAvg(lastOutpatientDiagTop20.getAvgFee());
							outpatientDiagTop20Record.setLastYearNum(lastOutpatientDiagTop20.getNum());
							outpatientDiagTop20Record.setLastYearDiagname(lastOutpatientDiagTop20.getDiagnoss());
						}
						
					}
				}
				list.add(outpatientDiagTop20Record);
				i++;
			}
		}
		outpatientDiagTop20Info.setList(list);
		
		
		System.out.println(records);
		System.out.println(preMonthRecords);
		System.out.println(lastYearRecords);
		return outpatientDiagTop20Info;
	}
	
	
	public List<OutpatientDiagTop20> getOutpatientDiagTop20(String startTime,String endTime,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setOrgCode(orgCode);
		List<OutpatientDiagTop20> list = mrInBasicMapper.getOutpatientDiagTop20(outPatientParam);
		System.out.println(list);
		for (OutpatientDiagTop20 outpatientDiagTop20 : list) {
			outPatientParam.setDiagName(outpatientDiagTop20.getDiagnoss());
			BigDecimal toatlFee = mrInBasicMapper.getTotalFeeByDiagnoss(outPatientParam);
			outpatientDiagTop20.setTotalFee(toatlFee);
			outpatientDiagTop20.setAvgFee(BigDecimalUtil.getDivide(toatlFee, new BigDecimal(outpatientDiagTop20.getNum())));
		}
		
		
		return  list;
		
	}

	
	
	@Override
	public OutpatientAppointmentInfo getOutpatientAppointment(StatisticalReportParam statisticalReportParam) {
		OutpatientAppointmentInfo  outpatientAppointmentInfo = new OutpatientAppointmentInfo();
		OutpatientAppointmnet records = getOutpatientAppointmnet(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),statisticalReportParam.getOrganizationId());
		OutpatientAppointmnet preMonthRecords = getOutpatientAppointmnet(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics2EndTime()),statisticalReportParam.getOrganizationId());
		OutpatientAppointmnet lastYearRecords = getOutpatientAppointmnet(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics3EndTime()),statisticalReportParam.getOrganizationId());
		System.out.println(records);
		System.out.println(preMonthRecords);
		System.out.println(lastYearRecords);
		
		//OutpatientAppointmnet [mzCount=384916, yuyueCount=98187]
		//OutpatientAppointmnet [mzCount=393755, yuyueCount=107842]
		//OutpatientAppointmnet [mzCount=306820, yuyueCount=79280]
		String note = "";
		if(records!=null) {
			
			BigDecimal yuyueRate = BigDecimalUtil.getDivideRate(new BigDecimal(records.getYuyueCount()), new BigDecimal(records.getMzCount()));
			
			note+="    "+statisticalReportParam.getStatics1Name()+"门诊提前预约的患者有"+records.getYuyueCount()+"人，预约率为"+yuyueRate+"%，";
			if(lastYearRecords!=null) {
				BigDecimal lastYearYuyueRate = BigDecimalUtil.getDivideRate(new BigDecimal(lastYearRecords.getYuyueCount()), new BigDecimal(lastYearRecords.getMzCount()));
				note+="比"+statisticalReportParam.getStatics3Name()+"的"+lastYearYuyueRate+"%"+BigDecimalUtil.getCompareResult(yuyueRate,lastYearYuyueRate)+BigDecimalUtil.getNumDifference(yuyueRate,lastYearYuyueRate)+"%，"+BigDecimalUtil.getCompareRateResult(yuyueRate,lastYearYuyueRate)+"为"+BigDecimalUtil.getCompareRate(yuyueRate,lastYearYuyueRate)+"%；";
			}
			
			if(preMonthRecords!=null) {
				BigDecimal preMonthYuyueRate = BigDecimalUtil.getDivideRate(new BigDecimal(preMonthRecords.getYuyueCount()), new BigDecimal(preMonthRecords.getMzCount()));
				note+="比"+statisticalReportParam.getStatics2Name()+"的"+preMonthYuyueRate+"%"+BigDecimalUtil.getCompareResult(yuyueRate,preMonthYuyueRate)+BigDecimalUtil.getNumDifference(yuyueRate,preMonthYuyueRate)+"%，"+BigDecimalUtil.getCompareRateResult(yuyueRate,preMonthYuyueRate)+"为"+BigDecimalUtil.getCompareRate(yuyueRate,preMonthYuyueRate)+"%.\n";
			}
			
		}
		
		
		
		OutpatientAppointmnet yyRecord = getOutpatientAppointmnetType(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),statisticalReportParam.getOrganizationId());
		if(yyRecord!=null) {
			note+="    门诊提前预约患者中通过电话、现场预约预约"+yyRecord.getDhyy()+"人次数、网络预约（官网、微信、支付宝）"+yyRecord.getWlyy()+"人次、诊间预约"+yyRecord.getZjyy()+"人次，其他预约"+yyRecord.getQtyy()+"人次。图3为各种预约方式构成图。\n";
	
		
			List<String> typeList = new LinkedList<String>();
			typeList.add("电话、现场预约");
			typeList.add("网络预约（官网、微信、支付宝）");
			typeList.add("诊间预约");
			typeList.add("其他");
			outpatientAppointmentInfo.setTypeList(typeList);
			

			List<Map<String,Object>> paramList = new LinkedList<Map<String,Object>>();
			Map<String,Object> map1 = new HashMap<>();
			map1.put("name", "电话、现场预约");
			map1.put("value", yyRecord.getDhyy());
			paramList.add(map1);
			
			Map<String,Object> map2 = new HashMap<>();
			map2.put("name", "网络预约（官网、微信、支付宝）");
			map2.put("value", yyRecord.getWlyy());
			paramList.add(map2);
			
			
			Map<String,Object> map3 = new HashMap<>();
			map3.put("name", "诊间预约");
			map3.put("value", yyRecord.getZjyy());
			paramList.add(map3);
			
			
			Map<String,Object> map4 = new HashMap<>();
			map4.put("name", "其他");
			map4.put("value", yyRecord.getQtyy());
			paramList.add(map4);
			
			outpatientAppointmentInfo.setParamList(paramList);
		}
		outpatientAppointmentInfo.setNote(note);
		
		return outpatientAppointmentInfo;
	}
	
	
	
	public OutpatientAppointmnet getOutpatientAppointmnet(String startTime,String endTime,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setOrgCode(orgCode);
		return  mrInBasicMapper.getOutpatientAppointment(outPatientParam);
		
	}
	
	
	public OutpatientAppointmnet getOutpatientAppointmnetType(String startTime,String endTime,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setOrgCode(orgCode);
		return  mrInBasicMapper.getOutpatientAppointmentType(outPatientParam);
		
	}

	
	@Override
	public OutpatientDeptInfo getOutpatientDeptInfo(StatisticalReportParam statisticalReportParam) {
		List<OutpatientDept> records = getOutpatientDept(DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1StartTime()),DateUtil.dateFormat("yyyy-MM-dd", statisticalReportParam.getStatics1EndTime()),statisticalReportParam.getOrganizationId());
		for (OutpatientDept outpatientDept : records) {
			System.out.println(outpatientDept);
		}
		return null;
	}
	
	public List<OutpatientDept> getOutpatientDept(String startTime,String endTime,String orgCode) {
		OutPatientParam outPatientParam = new OutPatientParam();
		String startTimeStr = startTime+" 00:00:00";
		String endTimeStr = endTime+" 23:59:59";
		outPatientParam.setStartTime(startTimeStr);
		outPatientParam.setEndTime(endTimeStr);
		outPatientParam.setOrgCode(orgCode);
		List<OutpatientDept>  records = mrInBasicMapper.getOutpatientByDept(outPatientParam);
		for (OutpatientDept outpatientDept : records) {
			
			if(StringUtils.isNotBlank(outpatientDept.getInDepa())) {
				outPatientParam.setInDepa(outpatientDept.getInDepa());
				outpatientDept.setYuyueCount(mrInBasicMapper.getYuyueCountByDept(outPatientParam));
				
				BigDecimal totalFee = mrInBasicMapper.getOutPatienttotalCharge(outPatientParam);
				if(totalFee!=null) {
					outpatientDept.setAvgFee(BigDecimalUtil.getDivide(totalFee, new BigDecimal(outpatientDept.getMzCount()), 2));
				}
			}
			
		}
		
		return  records;
		
	}
	
	
	
	public static void main(String[] args) {
		Map<String, String> params = new HashMap<>();
		params.put("orgcode", "49557184-0");
		params.put("start", "2020-10-01");
		params.put("end", "2020-10-31");
		params.put("outDepaId", null);
		params.put("branchId", null);
		params.put("length", "3");
		params.put("limit", "10");
		params.put("leader", null);
		params.put("cardid", null);
		params.put("jumpParam", "disease");
		params.put("sort","discharges");
		
		
		
	

		String json = HttpClientUtil.doPost("http://11.0.0.55:8999/medicalQuality/indicators", params);
		
		System.out.println(json);
		
		
		QualityInfo qualityInfo = JsonUtil.jsonToPojo(json, QualityInfo.class);
		
		System.out.println(qualityInfo);
		
		
	}
	
	


	
}
	
	
	
	

